26#include <onnxruntime_cxx_api.h>
33 std::string class_model_path = settings.nnClassificationPath, reg_model_path = settings.nnRegressionPath;
34 std::vector<std::string> reg_model_paths_local;
37 if (settings.nnLoadFromCCDB) {
38 reg_model_path = settings.nnLocalFolder +
"/net_regression_c1.onnx";
39 if (evalMode[0] ==
"c1") {
40 class_model_path = settings.nnLocalFolder +
"/net_classification_c1.onnx";
41 }
else if (evalMode[0] ==
"c2") {
42 class_model_path = settings.nnLocalFolder +
"/net_classification_c2.onnx";
45 if (evalMode[1] ==
"r2") {
46 reg_model_path +=
":" + settings.nnLocalFolder +
"/net_regression_c2.onnx";
51 {
"model-path", class_model_path},
52 {
"device-type", settings.nnInferenceDevice},
53 {
"allocate-device-memory",
std::to_string(settings.nnInferenceAllocateDevMem)},
54 {
"intra-op-num-threads",
std::to_string(settings.nnInferenceIntraOpNumThreads)},
55 {
"inter-op-num-threads",
std::to_string(settings.nnInferenceInterOpNumThreads)},
56 {
"enable-optimizations",
std::to_string(settings.nnInferenceEnableOrtOptimization)},
57 {
"deterministic-compute",
std::to_string(useDeterministicMode ? 1 : settings.nnInferenceUseDeterministicCompute)},
58 {
"enable-profiling",
std::to_string(settings.nnInferenceOrtProfiling)},
59 {
"profiling-output-path", settings.nnInferenceOrtProfilingPath},
61 {
"onnx-environment-name",
"c1"}};
68 if (!settings.nnClusterizerUseCfRegression) {
69 if (reg_model_paths_local.size() == 1) {
70 mOrtOptions[
"model-path"] = reg_model_paths_local[0];
75 mOrtOptions[
"model-path"] = reg_model_paths_local[0];
79 mOrtOptions[
"model-path"] = reg_model_paths_local[1];
113 clustererNN.
mNnClassThreshold = (float)std::log(settings.nnClassThreshold / (1.f - settings.nnClassThreshold));
117 if (settings.nnClusterizerVerbosity < 0) {
125 if (!settings.nnClusterizerUseCfRegression) {
173 void* Alloc(
size_t size);
175 const OrtMemoryInfo* Info()
const;
176 void* Reserve(
size_t size);
177 size_t NumAllocations()
const;
178 size_t NumReserveAllocations()
const;
186 std::atomic<size_t> memory_inuse{0};
187 std::atomic<size_t> num_allocations{0};
188 std::atomic<size_t> num_reserve_allocations{0};
189 OrtMemoryInfo* mMemoryInfoInternal;
195 OrtAllocator::version = ORT_API_VERSION;
201 mMemoryInfoInternal = info;
212 LOG(info) <<
"(ORT) Allocating direct memory of size " <<
size <<
" bytes";
218 LOG(info) <<
"(ORT) Reserving direct memory of size " <<
size <<
" bytes";
229 return mMemoryInfoInternal;
234 return num_allocations.load();
239 return num_reserve_allocations.load();
244 if (memory_inuse.load()) {
245 LOG(warning) <<
"memory leak!!!";
251 mMockedAlloc = std::make_shared<MockedOrtAllocator>(
rec, (OrtMemoryInfo*)(*memInfo));
253 Ort::ThrowOnError(Ort::GetApi().UnregisterAllocator((OrtEnv*)(*env), (OrtMemoryInfo*)(*memInfo)));
255 Ort::ThrowOnError(Ort::GetApi().RegisterAllocator((OrtEnv*)(*env),
mMockedAlloc.get()));
o2::ml::OrtModel mModelReg1
o2::ml::OrtModel mModelClass
const OrtMemoryInfo * getMockedMemoryInfo()
o2::ml::OrtModel mModelReg2
void init(const GPUSettingsProcessingNNclusterizer &, bool=false)
std::unordered_map< std::string, std::string > mOrtOptions
void initClusterizer(const GPUSettingsProcessingNNclusterizer &, GPUTPCNNClusterizer &)
MockedOrtAllocator * getMockedAllocator()
std::shared_ptr< MockedOrtAllocator > mMockedAlloc
std::vector< bool > mModelsUsed
void directOrtAllocator(Ort::Env *, Ort::MemoryInfo *, GPUReconstruction *, bool=false)
int32_t mNnClusterizerSizeInputTime
uint32_t mNnClusterizerRowTimeSize
int32_t mNnClusterizerSizeInputRow
int32_t mNnClusterizerSizeInputPad
uint32_t mNnClusterizerFullPadSize
int32_t mNnClusterizerBatchedMode
int32_t mNnClusterizerElementSize
int32_t mNnClusterizerModelReg1NumOutputNodes
int32_t mNnClusterizerVerbosity
int32_t mNnClusterizerUseCfRegression
int32_t mNnClusterizerModelClassNumOutputNodes
int32_t mNnClusterizerBoundaryFillValue
int8_t mNnClusterizerAddIndexData
int8_t mNnSigmoidTrafoClassThreshold
int32_t mNnInferenceInputDType
uint32_t mNnClusterizerRowTimeSizeFull
int32_t mNnInferenceOutputDType
uint32_t mNnClusterizerFullRowSize
int32_t mNnClusterizerModelReg2NumOutputNodes
int32_t mNnClusterizerChargeArraySize
uint32_t mNnClusterizerFullTimeSize
int8_t mNnClusterizerSetDeconvolutionFlags
uint32_t mNnClusterizerPadTimeSize
int8_t mNnClusterizerUseClassification
void initOptions(std::unordered_map< std::string, std::string > optionsMap)
std::vector< std::vector< int64_t > > getNumOutputNodes() const
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
std::string to_string(gsl::span< T, Size > span)
void * Alloc(size_t size)
size_t NumAllocations() const
const OrtMemoryInfo * Info() const
MockedOrtAllocator(GPUReconstruction *=nullptr, OrtMemoryInfo *=nullptr)
void * Reserve(size_t size)
size_t NumReserveAllocations() const
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"