forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampleConfig.h
More file actions
337 lines (299 loc) · 8.6 KB
/
sampleConfig.h
File metadata and controls
337 lines (299 loc) · 8.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*
* Copyright (c) 1993-2022, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SampleConfig_H
#define SampleConfig_H
#include <cstring>
#include <iostream>
#include <string>
#include "NvInfer.h"
#include "NvOnnxConfig.h"
class SampleConfig : public nvonnxparser::IOnnxConfig
{
public:
enum class InputDataFormat : int
{
kASCII = 0,
kPPM = 1
};
private:
std::string mModelFilename;
std::string mEngineFilename;
std::string mTextFilename;
std::string mFullTextFilename;
std::string mImageFilename;
std::string mReferenceFilename;
std::string mOutputFilename;
std::string mCalibrationFilename;
std::string mTimingCacheFilename;
int64_t mLabel{-1};
int64_t mMaxBatchSize{32};
int64_t mCalibBatchSize{0};
int64_t mMaxNCalibBatch{0};
int64_t mFirstCalibBatch{0};
int64_t mUseDLACore{-1};
nvinfer1::DataType mModelDtype{nvinfer1::DataType::kFLOAT};
bool mTF32{true};
Verbosity mVerbosity{static_cast<int>(nvinfer1::ILogger::Severity::kWARNING)};
bool mPrintLayercInfo{false};
bool mDebugBuilder{false};
InputDataFormat mInputDataFormat{InputDataFormat::kASCII};
uint64_t mTopK{0};
float mFailurePercentage{-1.0f};
float mTolerance{0.0f};
float mAbsTolerance{1e-5f};
public:
SampleConfig()
{
#ifdef ONNX_DEBUG
if (isDebug())
{
std::cout << " SampleConfig::ctor(): " << this << "\t" << std::endl;
}
#endif
}
protected:
~SampleConfig()
{
#ifdef ONNX_DEBUG
if (isDebug())
{
std::cout << "SampleConfig::dtor(): " << this << std::endl;
}
#endif
}
public:
void setModelDtype(const nvinfer1::DataType mdt) noexcept
{
mModelDtype = mdt;
}
nvinfer1::DataType getModelDtype() const noexcept
{
return mModelDtype;
}
bool getTF32() const noexcept
{
return mTF32;
}
void setTF32(bool enabled) noexcept
{
mTF32 = enabled;
}
const char* getModelFileName() const noexcept
{
return mModelFilename.c_str();
}
void setModelFileName(const char* onnxFilename) noexcept
{
mModelFilename = std::string(onnxFilename);
}
Verbosity getVerbosityLevel() const noexcept
{
return mVerbosity;
}
void addVerbosity() noexcept
{
++mVerbosity;
}
void reduceVerbosity() noexcept
{
--mVerbosity;
}
virtual void setVerbosityLevel(Verbosity v) noexcept
{
mVerbosity = v;
}
const char* getEngineFileName() const noexcept
{
return mEngineFilename.c_str();
}
void setEngineFileName(const char* engineFilename) noexcept
{
mEngineFilename = std::string(engineFilename);
}
const char* getTextFileName() const noexcept
{
return mTextFilename.c_str();
}
void setTextFileName(const char* textFilename) noexcept
{
mTextFilename = std::string(textFilename);
}
const char* getFullTextFileName() const noexcept
{
return mFullTextFilename.c_str();
}
void setFullTextFileName(const char* fullTextFilename) noexcept
{
mFullTextFilename = std::string(fullTextFilename);
}
void setLabel(int64_t label) noexcept
{
mLabel = label;
} //!< set the Label
int64_t getLabel() const noexcept
{
return mLabel;
} //!< get the Label
bool getPrintLayerInfo() const noexcept
{
return mPrintLayercInfo;
}
void setPrintLayerInfo(bool b) noexcept
{
mPrintLayercInfo = b;
} //!< get the boolean variable corresponding to the Layer Info, see getPrintLayerInfo()
void setMaxBatchSize(int64_t maxBatchSize) noexcept
{
mMaxBatchSize = maxBatchSize;
} //!< set the Max Batch Size
int64_t getMaxBatchSize() const noexcept
{
return mMaxBatchSize;
} //!< get the Max Batch Size
void setCalibBatchSize(int64_t CalibBatchSize) noexcept
{
mCalibBatchSize = CalibBatchSize;
} //!< set the calibration batch size
int64_t getCalibBatchSize() const noexcept
{
return mCalibBatchSize;
} //!< get calibration batch size
void setMaxNCalibBatch(int64_t MaxNCalibBatch) noexcept
{
mMaxNCalibBatch = MaxNCalibBatch;
} //!< set Max Number of Calibration Batches
int64_t getMaxNCalibBatch() const noexcept
{
return mMaxNCalibBatch;
} //!< get the Max Number of Calibration Batches
void setFirstCalibBatch(int64_t FirstCalibBatch) noexcept
{
mFirstCalibBatch = FirstCalibBatch;
} //!< set the first calibration batch
int64_t getFirstCalibBatch() const noexcept
{
return mFirstCalibBatch;
} //!< get the first calibration batch
void setUseDLACore(int64_t UseDLACore) noexcept
{
mUseDLACore = UseDLACore;
} //!< set the DLA core to use
int64_t getUseDLACore() const noexcept
{
return mUseDLACore;
} //!< get the DLA core to use
void setDebugBuilder() noexcept
{
mDebugBuilder = true;
} //!< enable the Debug info, while building the engine.
bool getDebugBuilder() const noexcept
{
return mDebugBuilder;
} //!< get the boolean variable, corresponding to the debug builder
const char* getImageFileName() const noexcept //!< set Image file name (PPM or ASCII)
{
return mImageFilename.c_str();
}
void setImageFileName(const char* imageFilename) noexcept //!< get the Image file name
{
mImageFilename = std::string(imageFilename);
}
const char* getReferenceFileName() const noexcept
{
return mReferenceFilename.c_str();
}
void setReferenceFileName(const char* referenceFilename) noexcept //!< set reference file name
{
mReferenceFilename = std::string(referenceFilename);
}
void setInputDataFormat(InputDataFormat idt) noexcept
{
mInputDataFormat = idt;
} //!< specifies expected data format of the image file (PPM or ASCII)
InputDataFormat getInputDataFormat() const noexcept
{
return mInputDataFormat;
} //!< returns the expected data format of the image file.
const char* getOutputFileName() const noexcept //!< specifies the file to save the results
{
return mOutputFilename.c_str();
}
void setOutputFileName(const char* outputFilename) noexcept //!< get the output file name
{
mOutputFilename = std::string(outputFilename);
}
const char* getCalibrationFileName() const noexcept
{
return mCalibrationFilename.c_str();
} //!< specifies the file containing the list of image files for int8 calibration
void setCalibrationFileName(const char* calibrationFilename) noexcept //!< get the int 8 calibration list file name
{
mCalibrationFilename = std::string(calibrationFilename);
}
uint64_t getTopK() const noexcept
{
return mTopK;
}
void setTopK(uint64_t topK) noexcept
{
mTopK = topK;
} //!< If this options is specified, return the K top probabilities.
float getFailurePercentage() const noexcept
{
return mFailurePercentage;
}
void setFailurePercentage(float f) noexcept
{
mFailurePercentage = f;
}
float getAbsoluteTolerance() const noexcept
{
return mAbsTolerance;
}
void setAbsoluteTolerance(float a) noexcept
{
mAbsTolerance = a;
}
float getTolerance() const noexcept
{
return mTolerance;
}
void setTolerance(float t) noexcept
{
mTolerance = t;
}
const char* getTimingCacheFilename() const noexcept
{
return mTimingCacheFilename.c_str();
}
void setTimingCacheFileName(const char* timingCacheFilename) noexcept
{
mTimingCacheFilename = std::string(timingCacheFilename);
}
bool isDebug() const noexcept
{
#if ONNX_DEBUG
return (std::getenv("ONNX_DEBUG") ? true : false);
#else
return false;
#endif
}
void destroy() noexcept
{
delete this;
}
}; // class SampleConfig
#endif