Skip to content

Commit 24bf104

Browse files
authored
Merge pull request #14 from alibuild/alibot-cleanup-13981
Please consider the following formatting changes to #13981
2 parents 9155cca + 05bc4b8 commit 24bf104

File tree

6 files changed

+60
-61
lines changed

6 files changed

+60
-61
lines changed

Common/ML/src/OrtInterface.cxx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void OrtModel::reset(std::unordered_map<std::string, std::string> optionsMap)
163163
[&](const std::string& str) { return str.c_str(); });
164164
}
165165
if (loggingLevel < 2) {
166-
LOG(info) << "(ORT) Model loaded successfully! (input: " << printShape(mInputShapes[0]) << ", output: " << printShape(mOutputShapes[0]) << ")";
166+
LOG(info) << "(ORT) Model loaded successfully! (input: " << printShape(mInputShapes[0]) << ", output: " << printShape(mOutputShapes[0]) << ")";
167167
}
168168
}
169169

@@ -197,9 +197,9 @@ std::string OrtModel::printShape(const std::vector<int64_t>& v)
197197
return ss.str();
198198
}
199199

200-
201-
template <class I, class O>
202-
std::vector<O> OrtModel::inference(std::vector<I>& input) {
200+
template <class I, class O>
201+
std::vector<O> OrtModel::inference(std::vector<I>& input)
202+
{
203203
std::vector<int64_t> inputShape{(int64_t)(input.size() / mInputShapes[0][1]), (int64_t)mInputShapes[0][1]};
204204
std::vector<Ort::Value> inputTensor;
205205
if constexpr (std::is_same_v<I, OrtDataType::Float16_t>) {
@@ -221,7 +221,6 @@ template std::vector<float> OrtModel::inference<OrtDataType::Float16_t, float>(s
221221

222222
template std::vector<OrtDataType::Float16_t> OrtModel::inference<OrtDataType::Float16_t, OrtDataType::Float16_t>(std::vector<OrtDataType::Float16_t>&);
223223

224-
225224
template <class I, class O>
226225
void OrtModel::inference(I* input, size_t input_size, O* output)
227226
{
@@ -232,22 +231,19 @@ void OrtModel::inference(I* input, size_t input_size, O* output)
232231
} else {
233232
inputTensor = Ort::Value::CreateTensor<I>(pImplOrt->memoryInfo, input, input_size, inputShape.data(), inputShape.size());
234233
}
235-
234+
236235
std::vector<int64_t> outputShape{inputShape[0], mOutputShapes[0][1]};
237236
size_t outputSize = (int64_t)(inputShape[0] * mOutputShapes[0][1]);
238237
Ort::Value outputTensor = Ort::Value::CreateTensor<O>(pImplOrt->memoryInfo, output, outputSize, outputShape.data(), outputShape.size());
239-
240-
(pImplOrt->session)->Run(pImplOrt->runOptions,
241-
inputNamesChar.data(), &inputTensor, 1,
242-
outputNamesChar.data(), &outputTensor, 1);
238+
239+
(pImplOrt->session)->Run(pImplOrt->runOptions, inputNamesChar.data(), &inputTensor, 1, outputNamesChar.data(), &outputTensor, 1);
243240
}
244241

245242
template void OrtModel::inference<OrtDataType::Float16_t, float>(OrtDataType::Float16_t*, size_t, float*);
246243

247244
template void OrtModel::inference<float, float>(float*, size_t, float*);
248245

249-
250-
template <class I, class O>
246+
template <class I, class O>
251247
std::vector<O> OrtModel::inference(std::vector<std::vector<I>>& input)
252248
{
253249
std::vector<Ort::Value> inputTensor;

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.cxx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,29 @@
1818

1919
using namespace o2::gpu;
2020

21-
void GPUTPCNNClusterizer::InitializeProcessor(){}
21+
void GPUTPCNNClusterizer::InitializeProcessor() {}
2222

23-
void GPUTPCNNClusterizer::SetMaxData(const GPUTrackingInOutPointers& io){}
23+
void GPUTPCNNClusterizer::SetMaxData(const GPUTrackingInOutPointers& io) {}
2424

25-
void* GPUTPCNNClusterizer::setIOPointers(void* mem) {
26-
if (nnClusterizerDtype == 0 && nnClusterizerElementSize > 0){
25+
void* GPUTPCNNClusterizer::setIOPointers(void* mem)
26+
{
27+
if (nnClusterizerDtype == 0 && nnClusterizerElementSize > 0) {
2728
computePointerWithAlignment(mem, inputData16, nnClusterizerBatchedMode * nnClusterizerElementSize);
28-
} else if (nnClusterizerDtype == 1 && nnClusterizerElementSize > 0){
29+
} else if (nnClusterizerDtype == 1 && nnClusterizerElementSize > 0) {
2930
computePointerWithAlignment(mem, inputData32, nnClusterizerBatchedMode * nnClusterizerElementSize);
3031
}
3132
computePointerWithAlignment(mem, peakPositions, nnClusterizerBatchedMode);
32-
computePointerWithAlignment(mem, clusterFlags, 2*nnClusterizerBatchedMode);
33+
computePointerWithAlignment(mem, clusterFlags, 2 * nnClusterizerBatchedMode);
3334
computePointerWithAlignment(mem, centralCharges, nnClusterizerBatchedMode);
3435
computePointerWithAlignment(mem, outputDataClass, nnClusterizerBatchedMode);
35-
if(nnClusterizerModelClassNumOutputNodes > 0) {
36+
if (nnClusterizerModelClassNumOutputNodes > 0) {
3637
computePointerWithAlignment(mem, modelProbabilities, nnClusterizerBatchedMode * nnClusterizerModelClassNumOutputNodes);
3738
}
3839
if (!nnClusterizerUseCfRegression) {
39-
if(nnClusterizerModelReg1NumOutputNodes > 0) {
40+
if (nnClusterizerModelReg1NumOutputNodes > 0) {
4041
computePointerWithAlignment(mem, outputDataReg1, nnClusterizerBatchedMode * nnClusterizerModelReg1NumOutputNodes);
4142
}
42-
if(nnClusterizerModelReg2NumOutputNodes > 0) {
43+
if (nnClusterizerModelReg2NumOutputNodes > 0) {
4344
computePointerWithAlignment(mem, outputDataReg2, nnClusterizerBatchedMode * nnClusterizerModelReg2NumOutputNodes);
4445
}
4546
}
@@ -49,7 +50,8 @@ void* GPUTPCNNClusterizer::setIOPointers(void* mem) {
4950
return mem;
5051
}
5152

52-
void GPUTPCNNClusterizer::RegisterMemoryAllocation() {
53+
void GPUTPCNNClusterizer::RegisterMemoryAllocation()
54+
{
5355
AllocateAndInitializeLate();
5456
int32_t memType = GPUMemoryResource::MEMORY_SCRATCH | GPUMemoryResource::MEMORY_STACK;
5557
mMemoryId = mRec->RegisterMemoryAllocation(this, &GPUTPCNNClusterizer::setIOPointers, memType, "TPCNNClusterer", GPUMemoryReuse{GPUMemoryReuse::REUSE_1TO1, GPUMemoryReuse::NNClusterer, (uint16_t)(mISector % mRec->GetProcessingSettings().nTPCClustererLanes)});

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace o2::OrtDataType
2222
{
23-
struct Float16_t;
23+
struct Float16_t;
2424
}
2525

2626
namespace o2::gpu
@@ -58,16 +58,16 @@ class GPUTPCNNClusterizer : public GPUProcessor
5858

5959
// Memory allocation for neural network
6060
uint class2_elements = 0;
61-
float* inputData32=nullptr;
62-
OrtDataType::Float16_t* inputData16=nullptr;
63-
float* outputDataClass=nullptr;
64-
float* modelProbabilities=nullptr;
65-
float* outputDataReg1=nullptr;
66-
float* outputDataReg2=nullptr;
61+
float* inputData32 = nullptr;
62+
OrtDataType::Float16_t* inputData16 = nullptr;
63+
float* outputDataClass = nullptr;
64+
float* modelProbabilities = nullptr;
65+
float* outputDataReg1 = nullptr;
66+
float* outputDataReg2 = nullptr;
6767

68-
ChargePos* peakPositions=nullptr;
69-
bool* clusterFlags=nullptr; // mSplitInTime, mSplitInPad. Techincally both flags are set in the same way -> ClusterAccumulator.cx=nullptrx
70-
float* centralCharges=nullptr;
68+
ChargePos* peakPositions = nullptr;
69+
bool* clusterFlags = nullptr; // mSplitInTime, mSplitInPad. Techincally both flags are set in the same way -> ClusterAccumulator.cx=nullptrx
70+
float* centralCharges = nullptr;
7171
int16_t mMemoryId = -1;
7272
}; // class GPUTPCNNClusterizer
7373

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerHost.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
using namespace o2::gpu;
2121

22-
GPUTPCNNClusterizerHost::GPUTPCNNClusterizerHost(const GPUSettingsProcessingNNclusterizer& settings, GPUTPCNNClusterizer& clusterer) {
22+
GPUTPCNNClusterizerHost::GPUTPCNNClusterizerHost(const GPUSettingsProcessingNNclusterizer& settings, GPUTPCNNClusterizer& clusterer)
23+
{
2324
OrtOptions = {
2425
{"model-path", settings.nnClassificationPath},
2526
{"device", settings.nnInferenceDevice},
@@ -30,8 +31,7 @@ GPUTPCNNClusterizerHost::GPUTPCNNClusterizerHost(const GPUSettingsProcessingNNcl
3031
{"enable-optimizations", std::to_string(settings.nnInferenceEnableOrtOptimization)},
3132
{"enable-profiling", std::to_string(settings.nnInferenceOrtProfiling)},
3233
{"profiling-output-path", settings.nnInferenceOrtProfilingPath},
33-
{"logging-level", std::to_string(settings.nnInferenceVerbosity)}
34-
};
34+
{"logging-level", std::to_string(settings.nnInferenceVerbosity)}};
3535

3636
model_class.init(OrtOptions);
3737
clusterer.nnClusterizerModelClassNumOutputNodes = model_class.getNumOutputNodes()[0][1];

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerHost.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace o2::ml;
2424

2525
namespace o2::OrtDataType
2626
{
27-
struct Float16_t;
27+
struct Float16_t;
2828
}
2929

3030
namespace o2::gpu
@@ -45,17 +45,18 @@ class GPUTPCNNClusterizerHost
4545
std::unordered_map<std::string, std::string> OrtOptions;
4646
o2::ml::OrtModel model_class, model_reg_1, model_reg_2; // For splitting clusters
4747
std::vector<std::string> reg_model_paths;
48-
private:
4948

49+
private:
5050
// Avoid including CommonUtils/StringUtils.h
51-
std::vector<std::string> splitString(const std::string& input, const std::string& delimiter) {
51+
std::vector<std::string> splitString(const std::string& input, const std::string& delimiter)
52+
{
5253
std::vector<std::string> tokens;
5354
std::size_t pos = 0;
5455
std::size_t found;
5556

5657
while ((found = input.find(delimiter, pos)) != std::string::npos) {
57-
tokens.push_back(input.substr(pos, found - pos));
58-
pos = found + delimiter.length();
58+
tokens.push_back(input.substr(pos, found - pos));
59+
pos = found + delimiter.length();
5960
}
6061
tokens.push_back(input.substr(pos));
6162

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerKernels.cxx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ GPUd() void GPUTPCNNClusterizerKernels::fillInputData(int32_t nBlocks, int32_t n
148148
for (int t = -clustererNN.nnClusterizerSizeInputTime; t <= clustererNN.nnClusterizerSizeInputTime; t++) {
149149
if (!is_boundary) {
150150
ChargePos tmp_pos(row + r, pad + p, time + t);
151-
if (r == 0 && !clustererNN.clusterFlags[2*glo_idx] && std::abs(p) < 3 && std::abs(t) < 3 && p != 0 && t != 0) { // ordering is done for short circuit optimization
152-
clustererNN.clusterFlags[2*glo_idx] = CfUtils::isPeak(isPeakMap[tmp_pos]);
153-
clustererNN.clusterFlags[2*glo_idx + 1] = clustererNN.clusterFlags[2*glo_idx];
151+
if (r == 0 && !clustererNN.clusterFlags[2 * glo_idx] && std::abs(p) < 3 && std::abs(t) < 3 && p != 0 && t != 0) { // ordering is done for short circuit optimization
152+
clustererNN.clusterFlags[2 * glo_idx] = CfUtils::isPeak(isPeakMap[tmp_pos]);
153+
clustererNN.clusterFlags[2 * glo_idx + 1] = clustererNN.clusterFlags[2 * glo_idx];
154154
}
155155
if (dtype == 0) {
156156
clustererNN.inputData16[write_idx] = (OrtDataType::Float16_t)(static_cast<float>(chargeMap[tmp_pos].unpack()) / central_charge);
@@ -222,12 +222,12 @@ GPUd() void GPUTPCNNClusterizerKernels::publishClustersReg1(uint glo_idx, GPUSha
222222
}
223223

224224
pc.setFull(clustererNN.centralCharges[glo_idx] * clustererNN.outputDataReg1[model_output_index + 4],
225-
static_cast<float>(clustererNN.peakPositions[glo_idx].pad()) + clustererNN.outputDataReg1[model_output_index],
226-
clustererNN.outputDataReg1[model_output_index + 2],
227-
static_cast<float>((clusterer.mPmemory->fragment).start) + static_cast<float>(clustererNN.peakPositions[glo_idx].time()) + clustererNN.outputDataReg1[model_output_index + 1],
228-
clustererNN.outputDataReg1[model_output_index + 3],
229-
clustererNN.clusterFlags[2*glo_idx],
230-
clustererNN.clusterFlags[2*glo_idx + 1]);
225+
static_cast<float>(clustererNN.peakPositions[glo_idx].pad()) + clustererNN.outputDataReg1[model_output_index],
226+
clustererNN.outputDataReg1[model_output_index + 2],
227+
static_cast<float>((clusterer.mPmemory->fragment).start) + static_cast<float>(clustererNN.peakPositions[glo_idx].time()) + clustererNN.outputDataReg1[model_output_index + 1],
228+
clustererNN.outputDataReg1[model_output_index + 3],
229+
clustererNN.clusterFlags[2 * glo_idx],
230+
clustererNN.clusterFlags[2 * glo_idx + 1]);
231231

232232
tpc::ClusterNative myCluster;
233233
bool rejectCluster = !pc.toNative(clustererNN.peakPositions[glo_idx], clustererNN.centralCharges[glo_idx], myCluster, clusterer.Param());
@@ -302,12 +302,12 @@ GPUd() void GPUTPCNNClusterizerKernels::publishClustersReg2(uint glo_idx, GPUSha
302302

303303
// Cluster 1
304304
pc.setFull(clustererNN.centralCharges[glo_idx] * clustererNN.outputDataReg2[model_output_index + 8],
305-
static_cast<float>(clustererNN.peakPositions[glo_idx].pad()) + clustererNN.outputDataReg2[model_output_index],
306-
clustererNN.outputDataReg2[model_output_index + 4],
307-
static_cast<float>((clusterer.mPmemory->fragment).start) + static_cast<float>(clustererNN.peakPositions[glo_idx].time()) + clustererNN.outputDataReg2[model_output_index + 2],
308-
clustererNN.outputDataReg2[model_output_index + 6],
309-
clustererNN.clusterFlags[2*glo_idx],
310-
clustererNN.clusterFlags[2*glo_idx + 1]);
305+
static_cast<float>(clustererNN.peakPositions[glo_idx].pad()) + clustererNN.outputDataReg2[model_output_index],
306+
clustererNN.outputDataReg2[model_output_index + 4],
307+
static_cast<float>((clusterer.mPmemory->fragment).start) + static_cast<float>(clustererNN.peakPositions[glo_idx].time()) + clustererNN.outputDataReg2[model_output_index + 2],
308+
clustererNN.outputDataReg2[model_output_index + 6],
309+
clustererNN.clusterFlags[2 * glo_idx],
310+
clustererNN.clusterFlags[2 * glo_idx + 1]);
311311

312312
tpc::ClusterNative myCluster;
313313
bool rejectCluster = !pc.toNative(clustererNN.peakPositions[glo_idx], clustererNN.centralCharges[glo_idx], myCluster, clusterer.Param());
@@ -337,12 +337,12 @@ GPUd() void GPUTPCNNClusterizerKernels::publishClustersReg2(uint glo_idx, GPUSha
337337

338338
// Cluster 2
339339
pc.setFull(clustererNN.centralCharges[glo_idx] * clustererNN.outputDataReg2[model_output_index + 9],
340-
static_cast<float>(clustererNN.peakPositions[glo_idx].pad()) + clustererNN.outputDataReg2[model_output_index + 1],
341-
clustererNN.outputDataReg2[model_output_index + 5],
342-
static_cast<float>((clusterer.mPmemory->fragment).start) + static_cast<float>(clustererNN.peakPositions[glo_idx].time()) + clustererNN.outputDataReg2[model_output_index + 3],
343-
clustererNN.outputDataReg2[model_output_index + 7],
344-
clustererNN.clusterFlags[2*glo_idx],
345-
clustererNN.clusterFlags[2*glo_idx + 1]);
340+
static_cast<float>(clustererNN.peakPositions[glo_idx].pad()) + clustererNN.outputDataReg2[model_output_index + 1],
341+
clustererNN.outputDataReg2[model_output_index + 5],
342+
static_cast<float>((clusterer.mPmemory->fragment).start) + static_cast<float>(clustererNN.peakPositions[glo_idx].time()) + clustererNN.outputDataReg2[model_output_index + 3],
343+
clustererNN.outputDataReg2[model_output_index + 7],
344+
clustererNN.clusterFlags[2 * glo_idx],
345+
clustererNN.clusterFlags[2 * glo_idx + 1]);
346346

347347
rejectCluster = !pc.toNative(clustererNN.peakPositions[glo_idx], clustererNN.centralCharges[glo_idx], myCluster, clusterer.Param());
348348
if (rejectCluster) {

0 commit comments

Comments
 (0)