Skip to content

Commit 1ca9fa0

Browse files
committed
Please consider the following formatting changes
1 parent e830697 commit 1ca9fa0

File tree

4 files changed

+92
-94
lines changed

4 files changed

+92
-94
lines changed

Common/ML/src/OrtInterface.cxx

Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void OrtModel::reset(std::unordered_map<std::string, std::string> optionsMap)
4444
if (!optionsMap.contains("model-path")) {
4545
LOG(fatal) << "(ORT) Model path cannot be empty!";
4646
}
47-
47+
4848
if (!optionsMap["model-path"].empty()) {
4949
modelPath = optionsMap["model-path"];
5050
device = (optionsMap.contains("device") ? optionsMap["device"] : "CPU");
@@ -83,85 +83,84 @@ void OrtModel::reset(std::unordered_map<std::string, std::string> optionsMap)
8383
#endif
8484
#endif
8585

86-
if (allocateDeviceMemory) {
87-
pImplOrt->memoryInfo = Ort::MemoryInfo(dev_mem_str.c_str(), OrtAllocatorType::OrtDeviceAllocator, deviceId, OrtMemType::OrtMemTypeDefault);
88-
LOG(info) << "(ORT) Memory info set to on-device memory";
89-
}
86+
if (allocateDeviceMemory) {
87+
pImplOrt->memoryInfo = Ort::MemoryInfo(dev_mem_str.c_str(), OrtAllocatorType::OrtDeviceAllocator, deviceId, OrtMemType::OrtMemTypeDefault);
88+
LOG(info) << "(ORT) Memory info set to on-device memory";
89+
}
9090

91-
if (device == "CPU") {
92-
(pImplOrt->sessionOptions).SetIntraOpNumThreads(intraOpNumThreads);
93-
if (intraOpNumThreads > 1) {
94-
(pImplOrt->sessionOptions).SetExecutionMode(ExecutionMode::ORT_PARALLEL);
95-
} else if (intraOpNumThreads == 1) {
96-
(pImplOrt->sessionOptions).SetExecutionMode(ExecutionMode::ORT_SEQUENTIAL);
97-
}
98-
if (loggingLevel < 2) {
99-
LOG(info) << "(ORT) CPU execution provider set with " << intraOpNumThreads << " threads";
100-
}
91+
if (device == "CPU") {
92+
(pImplOrt->sessionOptions).SetIntraOpNumThreads(intraOpNumThreads);
93+
if (intraOpNumThreads > 1) {
94+
(pImplOrt->sessionOptions).SetExecutionMode(ExecutionMode::ORT_PARALLEL);
95+
} else if (intraOpNumThreads == 1) {
96+
(pImplOrt->sessionOptions).SetExecutionMode(ExecutionMode::ORT_SEQUENTIAL);
97+
}
98+
if (loggingLevel < 2) {
99+
LOG(info) << "(ORT) CPU execution provider set with " << intraOpNumThreads << " threads";
101100
}
101+
}
102102

103-
(pImplOrt->sessionOptions).DisableMemPattern();
104-
(pImplOrt->sessionOptions).DisableCpuMemArena();
103+
(pImplOrt->sessionOptions).DisableMemPattern();
104+
(pImplOrt->sessionOptions).DisableCpuMemArena();
105105

106-
if (enableProfiling) {
107-
if (optionsMap.contains("profiling-output-path")) {
108-
(pImplOrt->sessionOptions).EnableProfiling((optionsMap["profiling-output-path"] + "/ORT_LOG_").c_str());
109-
} else {
110-
LOG(warning) << "(ORT) If profiling is enabled, optionsMap[\"profiling-output-path\"] should be set. Disabling profiling for now.";
111-
(pImplOrt->sessionOptions).DisableProfiling();
112-
}
106+
if (enableProfiling) {
107+
if (optionsMap.contains("profiling-output-path")) {
108+
(pImplOrt->sessionOptions).EnableProfiling((optionsMap["profiling-output-path"] + "/ORT_LOG_").c_str());
113109
} else {
110+
LOG(warning) << "(ORT) If profiling is enabled, optionsMap[\"profiling-output-path\"] should be set. Disabling profiling for now.";
114111
(pImplOrt->sessionOptions).DisableProfiling();
115112
}
113+
} else {
114+
(pImplOrt->sessionOptions).DisableProfiling();
115+
}
116116

117-
mInitialized = true;
118-
119-
(pImplOrt->sessionOptions).SetGraphOptimizationLevel(GraphOptimizationLevel(enableOptimizations));
120-
(pImplOrt->sessionOptions).SetLogSeverityLevel(OrtLoggingLevel(loggingLevel));
121-
122-
pImplOrt->env = std::make_shared<Ort::Env>(
123-
OrtLoggingLevel(loggingLevel),
124-
(optionsMap["onnx-environment-name"].empty() ? "onnx_model_inference" : optionsMap["onnx-environment-name"].c_str()),
125-
// Integrate ORT logging into Fairlogger
126-
[](void* param, OrtLoggingLevel severity, const char* category, const char* logid, const char* code_location, const char* message) {
127-
if (severity == ORT_LOGGING_LEVEL_VERBOSE) {
128-
LOG(debug) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
129-
} else if (severity == ORT_LOGGING_LEVEL_INFO) {
130-
LOG(info) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
131-
} else if (severity == ORT_LOGGING_LEVEL_WARNING) {
132-
LOG(warning) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
133-
} else if (severity == ORT_LOGGING_LEVEL_ERROR) {
134-
LOG(error) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
135-
} else if (severity == ORT_LOGGING_LEVEL_FATAL) {
136-
LOG(fatal) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
137-
} else {
138-
LOG(info) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
139-
}
140-
},
141-
(void*)3);
142-
(pImplOrt->env)->DisableTelemetryEvents(); // Disable telemetry events
143-
pImplOrt->session = std::make_shared<Ort::Session>(*(pImplOrt->env), modelPath.c_str(), pImplOrt->sessionOptions);
144-
145-
for (size_t i = 0; i < (pImplOrt->session)->GetInputCount(); ++i) {
146-
mInputNames.push_back((pImplOrt->session)->GetInputNameAllocated(i, pImplOrt->allocator).get());
147-
}
148-
for (size_t i = 0; i < (pImplOrt->session)->GetInputCount(); ++i) {
149-
mInputShapes.emplace_back((pImplOrt->session)->GetInputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape());
150-
}
151-
for (size_t i = 0; i < (pImplOrt->session)->GetOutputCount(); ++i) {
152-
mOutputNames.push_back((pImplOrt->session)->GetOutputNameAllocated(i, pImplOrt->allocator).get());
153-
}
154-
for (size_t i = 0; i < (pImplOrt->session)->GetOutputCount(); ++i) {
155-
mOutputShapes.emplace_back((pImplOrt->session)->GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape());
156-
}
117+
mInitialized = true;
118+
119+
(pImplOrt->sessionOptions).SetGraphOptimizationLevel(GraphOptimizationLevel(enableOptimizations));
120+
(pImplOrt->sessionOptions).SetLogSeverityLevel(OrtLoggingLevel(loggingLevel));
121+
122+
pImplOrt->env = std::make_shared<Ort::Env>(
123+
OrtLoggingLevel(loggingLevel),
124+
(optionsMap["onnx-environment-name"].empty() ? "onnx_model_inference" : optionsMap["onnx-environment-name"].c_str()),
125+
// Integrate ORT logging into Fairlogger
126+
[](void* param, OrtLoggingLevel severity, const char* category, const char* logid, const char* code_location, const char* message) {
127+
if (severity == ORT_LOGGING_LEVEL_VERBOSE) {
128+
LOG(debug) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
129+
} else if (severity == ORT_LOGGING_LEVEL_INFO) {
130+
LOG(info) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
131+
} else if (severity == ORT_LOGGING_LEVEL_WARNING) {
132+
LOG(warning) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
133+
} else if (severity == ORT_LOGGING_LEVEL_ERROR) {
134+
LOG(error) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
135+
} else if (severity == ORT_LOGGING_LEVEL_FATAL) {
136+
LOG(fatal) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
137+
} else {
138+
LOG(info) << "(ORT) [" << logid << "|" << category << "|" << code_location << "]: " << message;
139+
}
140+
},
141+
(void*)3);
142+
(pImplOrt->env)->DisableTelemetryEvents(); // Disable telemetry events
143+
pImplOrt->session = std::make_shared<Ort::Session>(*(pImplOrt->env), modelPath.c_str(), pImplOrt->sessionOptions);
157144

158-
inputNamesChar.resize(mInputNames.size(), nullptr);
159-
std::transform(std::begin(mInputNames), std::end(mInputNames), std::begin(inputNamesChar),
160-
[&](const std::string& str) { return str.c_str(); });
161-
outputNamesChar.resize(mOutputNames.size(), nullptr);
162-
std::transform(std::begin(mOutputNames), std::end(mOutputNames), std::begin(outputNamesChar),
163-
[&](const std::string& str) { return str.c_str(); });
145+
for (size_t i = 0; i < (pImplOrt->session)->GetInputCount(); ++i) {
146+
mInputNames.push_back((pImplOrt->session)->GetInputNameAllocated(i, pImplOrt->allocator).get());
147+
}
148+
for (size_t i = 0; i < (pImplOrt->session)->GetInputCount(); ++i) {
149+
mInputShapes.emplace_back((pImplOrt->session)->GetInputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape());
150+
}
151+
for (size_t i = 0; i < (pImplOrt->session)->GetOutputCount(); ++i) {
152+
mOutputNames.push_back((pImplOrt->session)->GetOutputNameAllocated(i, pImplOrt->allocator).get());
153+
}
154+
for (size_t i = 0; i < (pImplOrt->session)->GetOutputCount(); ++i) {
155+
mOutputShapes.emplace_back((pImplOrt->session)->GetOutputTypeInfo(i).GetTensorTypeAndShapeInfo().GetShape());
156+
}
164157

158+
inputNamesChar.resize(mInputNames.size(), nullptr);
159+
std::transform(std::begin(mInputNames), std::end(mInputNames), std::begin(inputNamesChar),
160+
[&](const std::string& str) { return str.c_str(); });
161+
outputNamesChar.resize(mOutputNames.size(), nullptr);
162+
std::transform(std::begin(mOutputNames), std::end(mOutputNames), std::begin(outputNamesChar),
163+
[&](const std::string& str) { return str.c_str(); });
165164
}
166165
}
167166

GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
897897
clusterer.nnClusterizerElementSize = ((2 * clusterer.nnClusterizerSizeInputRow + 1) * (2 * clusterer.nnClusterizerSizeInputPad + 1) * (2 * clusterer.nnClusterizerSizeInputTime + 1)) + (clusterer.nnClusterizerAddIndexData ? 3 : 0);
898898
clusterer.nnClusterizerBatchedMode = GetProcessingSettings().nnClusterizerBatchedMode;
899899
clusterer.nnClusterizerBoundaryFillValue = GetProcessingSettings().nnClusterizerBoundaryFillValue;
900-
if (GetProcessingSettings().nnClusterizerVerbosity < 0){
900+
if (GetProcessingSettings().nnClusterizerVerbosity < 0) {
901901
clusterer.nnClusterizerVerbosity = GetProcessingSettings().nnInferenceVerbosity;
902902
} else {
903903
clusterer.nnClusterizerVerbosity = GetProcessingSettings().nnClusterizerVerbosity;
@@ -933,7 +933,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
933933
clusterer.model_reg_2.init(clusterer.OrtOptions);
934934
}
935935
}
936-
936+
937937
if (clusterer.nnClusterizerUseCFregression || (int)(GetProcessingSettings().nnClusterizerApplyCfDeconvolution)) {
938938
runKernel<GPUTPCCFDeconvolution>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSlice}});
939939
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 4, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Split Charges");
@@ -943,12 +943,12 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
943943
// Inverse sigmoid transformation
944944
clusterer.nnClassThreshold = (float)std::log(clusterer.nnClassThreshold / (1.f - clusterer.nnClassThreshold));
945945
}
946-
946+
947947
float time_clusterizer = 0, time_fill = 0;
948948
int evalDtype = clusterer.OrtOptions["dtype"].find("32") != std::string::npos;
949949
clusterer.outputDataClass.resize(clusterer.mPmemory->counters.nClusters, -1);
950950

951-
for(int batch = 0; batch < std::ceil((float)clusterer.mPmemory->counters.nClusters / clusterer.nnClusterizerBatchedMode); batch++) {
951+
for (int batch = 0; batch < std::ceil((float)clusterer.mPmemory->counters.nClusters / clusterer.nnClusterizerBatchedMode); batch++) {
952952
uint batchStart = batch * clusterer.nnClusterizerBatchedMode;
953953
uint iSize = CAMath::Min((uint)clusterer.nnClusterizerBatchedMode, (uint)(clusterer.mPmemory->counters.nClusters - batchStart));
954954

@@ -967,7 +967,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
967967

968968
auto start1 = std::chrono::high_resolution_clock::now();
969969
GPUTPCNNClusterizer::applyNetworkClass(clusterer, evalDtype);
970-
if (clusterer.model_class.getNumOutputNodes()[0][1] == 1){
970+
if (clusterer.model_class.getNumOutputNodes()[0][1] == 1) {
971971
runKernel<GPUTPCNNClusterizer, GPUTPCNNClusterizer::determineClass1Labels>({GetGrid(iSize, lane, GPUReconstruction::krnlDeviceType::CPU), {iSlice}}, evalDtype, 0, batchStart); // Assigning class labels
972972
} else {
973973
runKernel<GPUTPCNNClusterizer, GPUTPCNNClusterizer::determineClass2Labels>({GetGrid(iSize, lane, GPUReconstruction::krnlDeviceType::CPU), {iSlice}}, evalDtype, 0, batchStart); // Assigning class labels
@@ -985,11 +985,10 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
985985

986986
time_clusterizer += std::chrono::duration_cast<std::chrono::nanoseconds>(stop1 - start1).count() / 1e9;
987987
time_fill += std::chrono::duration_cast<std::chrono::nanoseconds>(stop0 - start0).count() / 1e9;
988-
989988
}
990989

991990
auto start1 = std::chrono::high_resolution_clock::now();
992-
if(clusterer.nnClusterizerUseCFregression) {
991+
if (clusterer.nnClusterizerUseCFregression) {
993992
runKernel<GPUTPCNNClusterizer, GPUTPCNNClusterizer::runCfClusterizer>({GetGrid(clusterer.mPmemory->counters.nClusters, lane, GPUReconstruction::krnlDeviceType::CPU), {iSlice}}, evalDtype, 0, 0); // Running the CF regression kernel - no batching needed: batchStart = 0
994993
}
995994
auto stop1 = std::chrono::high_resolution_clock::now();

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.cxx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,27 @@ GPUdii() void GPUTPCNNClusterizer::Thread<GPUTPCNNClusterizer::publishClass2Regr
8383
GPUTPCNNClusterizer::publishClustersReg2(glo_idx, smem, clusterer, dtype, onlyMC, batchStart);
8484
}
8585

86-
87-
void GPUTPCNNClusterizer::applyNetworkClass(processorType& clusterer, int8_t dtype, uint batch_idx) {
88-
if(dtype == 0){
86+
void GPUTPCNNClusterizer::applyNetworkClass(processorType& clusterer, int8_t dtype, uint batch_idx)
87+
{
88+
if (dtype == 0) {
8989
clusterer.modelProbabilities = clusterer.model_class.inference<OrtDataType::Float16_t, float>(clusterer.inputData16);
9090
} else {
9191
clusterer.modelProbabilities = clusterer.model_class.inference<float, float>(clusterer.inputData32);
9292
}
9393
}
9494

95-
void GPUTPCNNClusterizer::applyNetworkReg1(processorType& clusterer, int8_t dtype) {
96-
if(dtype == 0){
95+
void GPUTPCNNClusterizer::applyNetworkReg1(processorType& clusterer, int8_t dtype)
96+
{
97+
if (dtype == 0) {
9798
clusterer.outputDataReg1 = clusterer.model_reg_1.inference<OrtDataType::Float16_t, float>(clusterer.inputData16);
9899
} else {
99100
clusterer.outputDataReg1 = clusterer.model_reg_1.inference<float, float>(clusterer.inputData32);
100101
}
101102
}
102103

103-
void GPUTPCNNClusterizer::applyNetworkReg2(processorType& clusterer, int8_t dtype) {
104-
if(dtype == 0){
104+
void GPUTPCNNClusterizer::applyNetworkReg2(processorType& clusterer, int8_t dtype)
105+
{
106+
if (dtype == 0) {
105107
clusterer.outputDataReg2 = clusterer.model_reg_2.inference<OrtDataType::Float16_t, float>(clusterer.inputData16);
106108
} else {
107109
clusterer.outputDataReg2 = clusterer.model_reg_2.inference<float, float>(clusterer.inputData32);
@@ -161,14 +163,14 @@ GPUd() void GPUTPCNNClusterizer::fillInputData(int32_t nBlocks, int32_t nThreads
161163
for (int t = -clusterer.nnClusterizerSizeInputTime; t <= clusterer.nnClusterizerSizeInputTime; t++) {
162164
if (!is_boundary) {
163165
ChargePos tmp_pos(row + r, pad + p, time + t);
164-
if(dtype == 0){
166+
if (dtype == 0) {
165167
clusterer.inputData16[write_idx] = (OrtDataType::Float16_t)(static_cast<float>(chargeMap[tmp_pos].unpack()) / central_charge);
166168
} else {
167169
clusterer.inputData32[write_idx] = static_cast<float>(chargeMap[tmp_pos].unpack()) / central_charge;
168170
}
169171
} else {
170172
// Filling boundary just to make sure that no values are left unintentionally
171-
if(dtype == 0){
173+
if (dtype == 0) {
172174
clusterer.inputData16[write_idx] = (OrtDataType::Float16_t)(static_cast<float>(clusterer.nnClusterizerBoundaryFillValue));
173175
} else {
174176
clusterer.inputData32[write_idx] = static_cast<float>(clusterer.nnClusterizerBoundaryFillValue);
@@ -179,7 +181,7 @@ GPUd() void GPUTPCNNClusterizer::fillInputData(int32_t nBlocks, int32_t nThreads
179181
}
180182
}
181183
if (clusterer.nnClusterizerAddIndexData) {
182-
if(dtype == 0){
184+
if (dtype == 0) {
183185
clusterer.inputData16[write_idx] = (OrtDataType::Float16_t)(clusterer.mISlice / 36.f);
184186
clusterer.inputData16[write_idx + 1] = (OrtDataType::Float16_t)(row / 152.f);
185187
clusterer.inputData16[write_idx + 2] = (OrtDataType::Float16_t)(static_cast<float>(pad) / clusterer.Param().tpcGeometry.NPads(row));

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ class GPUTPCNNClusterizer : public GPUKernelTemplate
7575
static void applyNetworkReg1(processorType&, int8_t = 0);
7676
static void applyNetworkReg2(processorType&, int8_t = 0);
7777

78-
79-
private:
80-
81-
static int padOffset(int, int, const GPUTPCGeometry&);
82-
static int rowOffset(int, int);
83-
static bool isBoundary(int, int, int, const GPUTPCGeometry&);
78+
private:
79+
static int padOffset(int, int, const GPUTPCGeometry&);
80+
static int rowOffset(int, int);
81+
static bool isBoundary(int, int, int, const GPUTPCGeometry&);
8482
};
8583

86-
} // namespace GPUCA_NAMESPACE::gpu
84+
} // namespace o2::gpu
8785

8886
#endif

0 commit comments

Comments
 (0)