|
40 | 40 | #endif |
41 | 41 |
|
42 | 42 | #ifdef GPUCA_HAS_ONNX |
43 | | -#include <CommonUtils/StringUtils.h> |
44 | 43 | #include "GPUTPCNNClusterizerKernels.h" |
45 | 44 | #include "GPUTPCNNClusterizerHost.h" |
46 | 45 | #endif |
@@ -613,51 +612,9 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) |
613 | 612 | } |
614 | 613 |
|
615 | 614 | #ifdef GPUCA_HAS_ONNX |
616 | | - GPUSettingsProcessingNNclusterizer nn_settings = GetProcessingSettings().nn; |
| 615 | + const GPUSettingsProcessingNNclusterizer& nn_settings = GetProcessingSettings().nn; |
617 | 616 | GPUTPCNNClusterizerHost nnApplication; // potentially this needs to be GPUTPCNNClusterizerHost nnApplication[NSECTORS]; Technically ONNX ->Run() is threadsafe at inference time since its read-only |
618 | 617 | if (GetProcessingSettings().nn.applyNNclusterizer) { |
619 | | - if(nn_settings.nnLoadFromCCDB) { |
620 | | - std::map<std::string, std::string> ccdbSettings = { |
621 | | - {"nnCCDBURL", nn_settings.nnCCDBURL}, |
622 | | - {"nnCCDBPath", nn_settings.nnCCDBPath}, |
623 | | - {"inputDType", nn_settings.nnInferenceInputDType}, |
624 | | - {"outputDType", nn_settings.nnInferenceOutputDType}, |
625 | | - {"nnCCDBWithMomentum", std::to_string(nn_settings.nnCCDBWithMomentum)}, |
626 | | - {"nnCCDBBeamType", nn_settings.nnCCDBBeamType}, |
627 | | - {"nnCCDBInteractionRate", std::to_string(nn_settings.nnCCDBInteractionRate)} |
628 | | - }; |
629 | | - |
630 | | - std::string nnFetchFolder = ""; |
631 | | - std::vector<std::string> fetchMode = o2::utils::Str::tokenize(nn_settings.nnCCDBFetchMode, ':'); |
632 | | - std::map<std::string, std::string> networkRetrieval = ccdbSettings; |
633 | | - |
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 |
646 | | - |
647 | | - networkRetrieval["nnCCDBLayerType"] = nn_settings.nnCCDBRegressionLayerType; |
648 | | - networkRetrieval["nnCCDBEvalType"] = "regression_c1"; |
649 | | - networkRetrieval["outputFile"] = nnFetchFolder + "net_regression_c1.onnx"; |
650 | | - 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 | | - } |
659 | | - } |
660 | | - |
661 | 618 | uint32_t maxClusters = 0; |
662 | 619 | nnApplication.init(nn_settings); |
663 | 620 | for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) { |
@@ -988,7 +945,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) |
988 | 945 | if (!clustererNN.nnClusterizerUseCfRegression) { |
989 | 946 | nnApplication.networkInference(nnApplication.model_reg_1, clustererNN, iSize, clustererNN.outputDataReg1, clustererNN.nnClusterizerDtype); |
990 | 947 | runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::publishClass1Regression>({GetGrid(iSize, lane), krnlRunRangeNone}, iSector, clustererNN.nnClusterizerDtype, withMC, batchStart); // Running the NN for regression class 1 |
991 | | - if (nnApplication.model_class.getNumOutputNodes()[0][1] > 1 && nnApplication.reg_model_paths.size() > 1) { |
| 948 | + if (nnApplication.model_class.getNumOutputNodes()[0][1] > 1 && nnApplication.model_reg_2.isInitialized()) { |
992 | 949 | nnApplication.networkInference(nnApplication.model_reg_2, clustererNN, iSize, clustererNN.outputDataReg2, clustererNN.nnClusterizerDtype); |
993 | 950 | runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::publishClass2Regression>({GetGrid(iSize, lane), krnlRunRangeNone}, iSector, clustererNN.nnClusterizerDtype, withMC, batchStart); // Running the NN for regression class 2 |
994 | 951 | } |
|
0 commit comments