1 | /** |
2 | * Copyright (c) Glow Contributors. See CONTRIBUTORS file. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | #ifndef GLOW_FLAGS_FLAGS_H |
17 | #define GLOW_FLAGS_FLAGS_H |
18 | |
19 | #include "llvm/ADT/StringRef.h" |
20 | #include <gflags/gflags.h> |
21 | #include <map> |
22 | |
23 | namespace glow { |
24 | namespace flags { |
25 | |
26 | // Generic Constants |
27 | extern int32_t NumDevices; |
28 | extern bool ScanDevices; |
29 | extern bool SaturateHost; |
30 | extern bool EnableQuantParamChanges; |
31 | extern size_t MaxActiveRequests; |
32 | extern size_t MaxActiveRequestsPerInstance; |
33 | extern size_t MaxQueueSize; |
34 | extern size_t ExecutorThreads; |
35 | extern bool DelayAndRecordConstantModification; |
36 | extern bool UseTrackedDummyQuantParams; |
37 | extern bool EnablePartialTensors; |
38 | extern bool UseCustomOpsForExport; |
39 | extern std::string BackendSpecificOpts; |
40 | extern bool EnableLoadBalancedPartitioning; |
41 | extern bool SkipProvisioning; |
42 | extern bool DisableLayoutVerifying; |
43 | extern bool DisableFreeCompilationResource; |
44 | extern bool SinkTanhBelowConcat; |
45 | |
46 | // FP16 Constants |
47 | extern bool ConvertToFP16; |
48 | extern bool SkipBiasFp32tofp16Convert; |
49 | extern bool ConvertPlaceholdersToFP16; |
50 | extern bool ConvertConstantsToFP16; |
51 | extern bool ConvertFusedScaleOffsetToFP16; |
52 | extern bool ClipToFP16; |
53 | extern bool SkipInputsOnClipToFP16; |
54 | extern bool ForceSLSToFP16Accum; |
55 | extern bool ClipZeroScaleFP16; |
56 | extern bool ClipQuantRangeToFP16; |
57 | |
58 | // FP32 constants |
59 | extern bool ConvertFusedScaleOffsetToFP32; |
60 | |
61 | // Debug Constants |
62 | extern int32_t NumDebugTracesPerDump; |
63 | extern bool DumpDebugTraces; |
64 | extern bool LogPartition; |
65 | extern bool DumpPartition; |
66 | extern bool DumpCompilationLog; |
67 | extern bool DumpBackendSpecificIRJSON; |
68 | extern bool DumpGraph; |
69 | extern std::string DumpGraphPath; |
70 | extern bool DumpInitialLoadedGraph; |
71 | |
72 | // Sparse NN Partitioning Scheme Constants |
73 | extern int32_t ; |
74 | extern int64_t SparseNNPartitioningSchemeSLSTableKBytesPerCard; |
75 | extern int32_t ; |
76 | extern int32_t ; |
77 | extern bool UseSparseNNPartitioningScheme; |
78 | extern bool SparseNNPartitioningAddSLSConcats; |
79 | extern bool SparseNNPartitioningBalancePerfModel; |
80 | extern bool SparseNNPartitioningPairLNWithSLS; |
81 | extern bool SparseNNPartitioningPairTileWithSLS; |
82 | extern std::string SparseNNPartitioningPairSLSWith; |
83 | extern int32_t SparseNNPartitioningConcatSplitSize; |
84 | extern bool SparseNNParallelizeReshapeOnBatchDim; |
85 | |
86 | // Dag Optimizer Constants |
87 | extern bool UseDAGOptimizer; |
88 | extern int32_t DAGOptimizerNumParallelChunks; |
89 | extern std::string DAGOptimizerPlacementTaggingAlgorithm; |
90 | extern std::string DAGOptimizerParallelizationTaggingAlgorithm; |
91 | |
92 | /// Helper for processing opts in \p optsStr into \p opts. \returns if there is |
93 | /// any error encountered when processing \p optsStr. |
94 | bool processBackendSpecificOpts(std::map<std::string, std::string> &optsMap, |
95 | llvm::StringRef optsStr); |
96 | } // namespace flags |
97 | } // namespace glow |
98 | |
99 | namespace glow { |
100 | namespace nnpi { |
101 | namespace flags { |
102 | extern int32_t ModelParallelSplitAlignment; |
103 | extern int32_t NumParallelChunks; |
104 | extern bool LowerAllBatchMatMul; |
105 | extern bool AcceptUnarySLS; |
106 | extern bool SpecializeAllOneSLS; |
107 | extern bool DisableTransforms; |
108 | extern bool EnableCustomIAKernels; |
109 | extern bool EnableCustomDSPKernels; |
110 | extern bool DumpCompilerData; |
111 | extern bool UsePerPartitionIcetConfig; |
112 | extern std::string InjectedIAOpKernelPath; |
113 | extern bool DumpCustomKernelFiles; |
114 | } // namespace flags |
115 | } // namespace nnpi |
116 | } // namespace glow |
117 | |
118 | namespace glow { |
119 | namespace interpreter { |
120 | namespace flags { |
121 | extern bool LowerBatchMatMul; |
122 | extern bool LowerLayerNormalization; |
123 | } // namespace flags |
124 | } // namespace interpreter |
125 | } // namespace glow |
126 | |
127 | namespace glow { |
128 | namespace torch_glow { |
129 | namespace flags { |
130 | extern bool ImaginaryFlag; // Placeholder Flag |
131 | } |
132 | } // namespace torch_glow |
133 | } // namespace glow |
134 | |
135 | namespace glow { |
136 | namespace onnxifi { |
137 | namespace flags { |
138 | extern std::string BackendName; |
139 | extern bool SaveModel; |
140 | extern bool SaveIO; |
141 | extern bool SaveDAG; |
142 | extern bool SaveDAGWithConstants; |
143 | extern bool SaveDAGInZipMode; |
144 | } // namespace flags |
145 | } // namespace onnxifi |
146 | } // namespace glow |
147 | |
148 | namespace glow { |
149 | namespace runtime { |
150 | namespace flags { |
151 | extern unsigned CPUMemory; |
152 | |
153 | extern unsigned HabanaMemory; |
154 | |
155 | extern unsigned NNPIMemory; |
156 | extern unsigned NNPITimeoutMs; |
157 | |
158 | extern std::string AvailableDevices; |
159 | extern unsigned InterpreterMemory; |
160 | extern bool EnableP2P; |
161 | extern bool EnableDRT; |
162 | extern unsigned DeviceInitTimeoutMs; |
163 | extern uint64_t BigTableThresholdBytes; |
164 | extern unsigned SanitizeInputsPercent; |
165 | extern unsigned NumCompilationThreads; |
166 | } // namespace flags |
167 | } // namespace runtime |
168 | } // namespace glow |
169 | |
170 | /// Flags which may have their default values overridden: |
171 | DECLARE_bool(glow_global_fp16); |
172 | DECLARE_bool(glow_skip_bias_fp32tofp16_convert); |
173 | DECLARE_bool(glow_clip_fp16); |
174 | DECLARE_bool(glow_global_fused_scale_offset_fp16); |
175 | DECLARE_bool(glow_global_fused_scale_offset_fp32); |
176 | DECLARE_int32(glow_snn_partitioning_kbytes_per_card); |
177 | DECLARE_int32(glow_snn_partitioning_num_cores_sls); |
178 | DECLARE_int32(glow_snn_partitioning_num_cores_other); |
179 | |
180 | /// Signifiers for flags which we may load from e.g. a proto. |
181 | constexpr char clipQuantRangeToFP16Key[] = "GlowLoader_clipQuantRangeToFP16" ; |
182 | |
183 | #endif /* GLOW_FLAGS_FLAGS_H */ |
184 | |