Skip to content

Commit ad4b22b

Browse files
committed
Improve fetching, but have to pass settings by value, not const ref
1 parent d767ed1 commit ad4b22b

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ AddOption(nnSigmoidTrafoClassThreshold, int, 1, "", 0, "If true (default), then
255255
AddOption(nnLoadFromCCDB, int, 1, "", 0, "If 1 networks are fetched from ccdb, else locally")
256256
AddOption(nnCCDBURL, std::string, "http://ccdb-test.cern.ch:8080", "", 0, "The CCDB URL from where the network files are fetched")
257257
AddOption(nnCCDBPath, std::string, "Users/c/csonnabe/TPC/Clusterization", "", 0, "Folder path containing the networks")
258+
AddOption(nnCCDBFetchMode, std::string, "c1:r1", "", 0, "Concatention of modes, e.g. c1:r1 (classification class 1, regression class 1)")
258259
AddOption(nnCCDBWithMomentum, int, 1, "", 0, "Distinguishes between the network with and without momentum output for the regression")
259260
AddOption(nnCCDBClassificationLayerType, std::string, "FC", "", 0, "Distinguishes between network with different layer types. Options: FC, CNN")
260261
AddOption(nnCCDBRegressionLayerType, std::string, "CNN", "", 0, "Distinguishes between network with different layer types. Options: FC, CNN")

GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#endif
4141

4242
#ifdef GPUCA_HAS_ONNX
43+
#include <CommonUtils/StringUtils.h>
4344
#include "GPUTPCNNClusterizerKernels.h"
4445
#include "GPUTPCNNClusterizerHost.h"
4546
#endif
@@ -612,7 +613,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
612613
}
613614

614615
#ifdef GPUCA_HAS_ONNX
615-
const GPUSettingsProcessingNNclusterizer& nn_settings = GetProcessingSettings().nn;
616+
GPUSettingsProcessingNNclusterizer nn_settings = GetProcessingSettings().nn;
616617
GPUTPCNNClusterizerHost nnApplication; // potentially this needs to be GPUTPCNNClusterizerHost nnApplication[NSECTORS]; Technically ONNX ->Run() is threadsafe at inference time since its read-only
617618
if (GetProcessingSettings().nn.applyNNclusterizer) {
618619
if(nn_settings.nnLoadFromCCDB) {
@@ -626,17 +627,35 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
626627
{"nnCCDBInteractionRate", std::to_string(nn_settings.nnCCDBInteractionRate)}
627628
};
628629

630+
std::string nnFetchFolder = "";
631+
std::vector<std::string> fetchMode = o2::utils::Str::tokenize(nn_settings.nnCCDBFetchMode, ':');
629632
std::map<std::string, std::string> networkRetrieval = ccdbSettings;
630633

631-
networkRetrieval["nnCCDBLayerType"] = nn_settings.nnCCDBClassificationLayerType;
632-
networkRetrieval["nnCCDBEvalType"] = "classification_c1";
633-
networkRetrieval["outputFile"] = "net_classification_c1.onnx";
634-
nnApplication.loadFromCCDB(networkRetrieval);
634+
if (fetchMode[0] == "c1") {
635+
networkRetrieval["nnCCDBLayerType"] = nn_settings.nnCCDBClassificationLayerType;
636+
networkRetrieval["nnCCDBEvalType"] = "classification_c1";
637+
networkRetrieval["outputFile"] = nnFetchFolder + "net_classification_c1.onnx";
638+
nnApplication.loadFromCCDB(networkRetrieval);
639+
} else if (fetchMode[0] == "c2") {
640+
networkRetrieval["nnCCDBLayerType"] = nn_settings.nnCCDBClassificationLayerType;
641+
networkRetrieval["nnCCDBEvalType"] = "classification_c2";
642+
networkRetrieval["outputFile"] = nnFetchFolder + "net_classification_c2.onnx";
643+
nnApplication.loadFromCCDB(networkRetrieval);
644+
}
645+
nn_settings.nnClassificationPath = networkRetrieval["outputFile"]; // Setting the proper path from the where the models will be initialized locally
635646

636647
networkRetrieval["nnCCDBLayerType"] = nn_settings.nnCCDBRegressionLayerType;
637648
networkRetrieval["nnCCDBEvalType"] = "regression_c1";
638-
networkRetrieval["outputFile"] = "net_regression_c1.onnx";
649+
networkRetrieval["outputFile"] = nnFetchFolder + "net_regression_c1.onnx";
639650
nnApplication.loadFromCCDB(networkRetrieval);
651+
nn_settings.nnRegressionPath = networkRetrieval["outputFile"];
652+
if (fetchMode[1] == "r2") {
653+
networkRetrieval["nnCCDBLayerType"] = nn_settings.nnCCDBRegressionLayerType;
654+
networkRetrieval["nnCCDBEvalType"] = "regression_c2";
655+
networkRetrieval["outputFile"] = nnFetchFolder + "net_regression_c2.onnx";
656+
nnApplication.loadFromCCDB(networkRetrieval);
657+
nn_settings.nnRegressionPath += ":", networkRetrieval["outputFile"];
658+
}
640659
}
641660

642661
uint32_t maxClusters = 0;

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerHost.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
using namespace o2::gpu;
2424

25-
GPUTPCNNClusterizerHost::GPUTPCNNClusterizerHost(const GPUSettingsProcessingNNclusterizer& settings)
25+
GPUTPCNNClusterizerHost::GPUTPCNNClusterizerHost(GPUSettingsProcessingNNclusterizer settings)
2626
{
2727
init(settings);
2828
}
@@ -53,7 +53,7 @@ void GPUTPCNNClusterizerHost::loadFromCCDB(std::map<std::string, std::string> se
5353
}
5454
}
5555

56-
void GPUTPCNNClusterizerHost::init(const GPUSettingsProcessingNNclusterizer& settings)
56+
void GPUTPCNNClusterizerHost::init(GPUSettingsProcessingNNclusterizer settings)
5757
{
5858
OrtOptions = {
5959
{"model-path", settings.nnClassificationPath},

GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizerHost.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class GPUTPCNNClusterizerHost
3737
{
3838
public:
3939
GPUTPCNNClusterizerHost() = default;
40-
GPUTPCNNClusterizerHost(const GPUSettingsProcessingNNclusterizer&);
40+
GPUTPCNNClusterizerHost(GPUSettingsProcessingNNclusterizer);
4141

42-
void init(const GPUSettingsProcessingNNclusterizer&);
42+
void init(GPUSettingsProcessingNNclusterizer);
4343
void initClusterizer(const GPUSettingsProcessingNNclusterizer&, GPUTPCNNClusterizer&);
4444
void loadFromCCDB(std::map<std::string, std::string>);
4545

0 commit comments

Comments
 (0)