Skip to content

Commit b148f09

Browse files
authored
Merge branch 'AliceO2Group:dev' into new-detector4
2 parents 67a233c + 04baff0 commit b148f09

File tree

194 files changed

+4121
-2547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+4121
-2547
lines changed

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ T* CCDBManagerInstance::getForRun(std::string const& path, int runNumber, bool s
330330
template <typename T>
331331
T* CCDBManagerInstance::getSpecificForRun(std::string const& path, int runNumber, MD metaData)
332332
{
333-
auto [start, stop] = getRunDuration(runNumber);
333+
auto [start, stop] = getRunDuration(runNumber, mFatalWhenNull);
334334
if (start < 0 || stop < 0) {
335335
if (mFatalWhenNull) {
336336
reportFatal(std::string("Failed to get run duration for run ") + std::to_string(runNumber) + std::string(" from CCDB"));

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ o2_build_sanity_checks()
4141
set(CMAKE_CXX_STANDARD 20)
4242
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
4343

44-
include(dependencies/FindONNXRuntime.cmake)
45-
4644
include(O2CheckCXXFeatures)
4745
o2_check_cxx_features()
4846

Common/Constants/include/CommonConstants/PhysicsConstants.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum Pdg {
3434
kB0 = 511,
3535
kB0Bar = -511,
3636
kBPlus = 521,
37+
kBCPlus = 541,
3738
kBS = 531,
3839
kBSBar = -531,
3940
kD0 = 421,
@@ -63,6 +64,8 @@ enum Pdg {
6364
kPhi = 333,
6465
kSigmaC0 = 4112,
6566
kSigmaCPlusPlus = 4222,
67+
kSigmaCStar0 = 4114,
68+
kSigmaCStarPlusPlus = 4224,
6669
kX3872 = 9920443,
6770
kXi0 = 3322,
6871
kXiB0 = 5232,
@@ -84,6 +87,7 @@ enum Pdg {
8487
constexpr double MassB0 = 5.27966;
8588
constexpr double MassB0Bar = 5.27966;
8689
constexpr double MassBPlus = 5.27934;
90+
constexpr double MassBCPlus = 6.27447;
8791
constexpr double MassBS = 5.36692;
8892
constexpr double MassBSBar = 5.36692;
8993
constexpr double MassD0 = 1.86484;
@@ -113,6 +117,8 @@ constexpr double MassKPlusStar892 = 0.89167;
113117
constexpr double MassPhi = 1.019461;
114118
constexpr double MassSigmaC0 = 2.45375;
115119
constexpr double MassSigmaCPlusPlus = 2.45397;
120+
constexpr double MassSigmaCStar0 = 2.51848;
121+
constexpr double MassSigmaCStarPlusPlus = 2.51841;
116122
constexpr double MassX3872 = 3.87165;
117123
constexpr double MassXi0 = 1.31486;
118124
constexpr double MassXiB0 = 5.7919;

Common/Constants/include/CommonConstants/make_pdg_header.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class Pdg(Enum):
8989
kB0 = 511
9090
kB0Bar = -511
9191
kBPlus = 521
92+
kBCPlus = 541
9293
kBS = 531
9394
kBSBar = -531
9495
kD0 = 421
@@ -118,6 +119,8 @@ class Pdg(Enum):
118119
kPhi = 333
119120
kSigmaC0 = 4112
120121
kSigmaCPlusPlus = 4222
122+
kSigmaCStar0 = 4114
123+
kSigmaCStarPlusPlus = 4224
121124
kX3872 = 9920443
122125
kXi0 = 3322
123126
kXiB0 = 5232

Common/DCAFitter/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,41 @@ In this case the relevant correlation coefficient of the cov.matrix is redefined
9393

9494
`DCAFitterN::setBadCovPolicy(DCAFitterN::OverrideAnFlag);` continue fit with overridden cov.matrix but set the propagation failure flag (can be checked using the same `isPropagationFailure(int cand = 0)` method).
9595

96+
## Fit status
97+
The fitter provides a fit status for each candidate, which can be retrieved using:
98+
```
99+
FitStatus status = ft.getFitStatus(int cand = 0);
100+
```
101+
The possible values are:
102+
```
103+
enum FitStatus : uint8_t { // part of the DCAFitterN class
104+
None, // no status set (should not be possible!)
105+
106+
/* Good Conditions */
107+
Converged, // fit converged
108+
MaxIter, // max iterations reached before fit convergence (can still be a good vertex)
109+
110+
/* Error Conditions */
111+
NoCrossing, // no reasonable crossing was found
112+
RejRadius, // radius of crossing was not acceptable
113+
RejTrackX, // one candidate track x was below the minimum required radius
114+
RejTrackRoughZ, // rejected by rough cut on tracks Z difference
115+
RejChi2Max, // rejected by maximum chi2 cut
116+
FailProp, // propagation of at least prong to PCA failed
117+
FailInvCov, // inversion of cov.-matrix failed
118+
FailInvWeight, // inversion of Ti weight matrix failed
119+
FailInv2ndDeriv, // inversion of 2nd derivatives failed
120+
FailCorrTracks, // correction of tracks to updated x failed
121+
FailCloserAlt, // alternative PCA is closer
122+
};
123+
```
124+
This is allows to track where candiate fit was abondended.
125+
```
126+
int nc = ft.process(tr0,tr1,tr2);
127+
auto status = ft.getFitStatus();
128+
if (nc) {
129+
// status can either be FitStatus::Converged or FitStatus::MaxIter
130+
}
131+
// status can be on of the error conditions
132+
```
133+
A more thorough example is given in `testDCAFitterN.cxx`.

Common/ML/CMakeLists.txt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,14 @@
99
# granted to it by virtue of its status as an Intergovernmental Organization
1010
# or submit itself to any jurisdiction.
1111

12-
# Pass ORT variables as a preprocessor definition
13-
if(ORT_ROCM_BUILD)
14-
add_compile_definitions(ORT_ROCM_BUILD=1)
15-
endif()
16-
if(ORT_CUDA_BUILD)
17-
add_compile_definitions(ORT_CUDA_BUILD=1)
18-
endif()
19-
if(ORT_MIGRAPHX_BUILD)
20-
add_compile_definitions(ORT_MIGRAPHX_BUILD=1)
21-
endif()
22-
if(ORT_TENSORRT_BUILD)
23-
add_compile_definitions(ORT_TENSORRT_BUILD=1)
24-
endif()
25-
2612
o2_add_library(ML
2713
SOURCES src/OrtInterface.cxx
2814
TARGETVARNAME targetName
29-
PRIVATE_LINK_LIBRARIES O2::Framework ONNXRuntime::ONNXRuntime)
15+
PRIVATE_LINK_LIBRARIES O2::GPUCommon onnxruntime::onnxruntime)
16+
17+
# Pass ORT variables as a preprocessor definition
18+
target_compile_definitions(${targetName} PRIVATE
19+
$<$<BOOL:${ORT_ROCM_BUILD}>:ORT_ROCM_BUILD>
20+
$<$<BOOL:${ORT_CUDA_BUILD}>:ORT_CUDA_BUILD>
21+
$<$<BOOL:${ORT_MIGRAPHX_BUILD}>:ORT_MIGRAPHX_BUILD>
22+
$<$<BOOL:${ORT_TENSORRT_BUILD}>:ORT_TENSORRT_BUILD>)

Common/ML/include/ML/3rdparty/GPUORTFloat16.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,22 +535,22 @@ GPUdi() uint16_t BFloat16Impl<Derived>::ToUint16Impl(float v) noexcept
535535
result = kPositiveQNaNBits;
536536
} else {
537537
auto get_msb_half = [](float fl) {
538-
uint16_t result;
538+
uint16_t res;
539539
#ifdef GPUCA_GPUCODE
540-
o2::gpu::CAMath::memcpy(&result, reinterpret_cast<char*>(&fl) + sizeof(uint16_t), sizeof(uint16_t));
540+
o2::gpu::CAMath::memcpy(&res, reinterpret_cast<char*>(&fl) + sizeof(uint16_t), sizeof(uint16_t));
541541
#else
542542
#ifdef __cpp_if_constexpr
543543
if constexpr (detail::endian::native == detail::endian::little)
544544
#else
545545
if (detail::endian::native == detail::endian::little)
546546
#endif
547547
{
548-
std::memcpy(&result, reinterpret_cast<char*>(&fl) + sizeof(uint16_t), sizeof(uint16_t));
548+
std::memcpy(&res, reinterpret_cast<char*>(&fl) + sizeof(uint16_t), sizeof(uint16_t));
549549
} else {
550-
std::memcpy(&result, &fl, sizeof(uint16_t));
550+
std::memcpy(&res, &fl, sizeof(uint16_t));
551551
}
552552
#endif
553-
return result;
553+
return res;
554554
};
555555

556556
uint16_t upper_bits = get_msb_half(v);
@@ -882,4 +882,4 @@ static_assert(sizeof(BFloat16_t) == sizeof(uint16_t), "Sizes must match");
882882
} // namespace OrtDataType
883883

884884
} // namespace o2
885-
#endif
885+
#endif

Common/ML/include/ML/OrtInterface.h

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@
2222
#include <memory>
2323
#include <map>
2424
#include <thread>
25+
#include <unordered_map>
2526

2627
// O2 includes
27-
#include "Framework/Logger.h"
28+
#include "GPUCommonLogger.h"
29+
30+
namespace Ort
31+
{
32+
struct SessionOptions;
33+
struct MemoryInfo;
34+
struct Env;
35+
} // namespace Ort
2836

2937
namespace o2
3038
{
@@ -36,14 +44,52 @@ class OrtModel
3644
{
3745

3846
public:
39-
// Constructor
47+
// Constructors & destructors
4048
OrtModel() = default;
41-
OrtModel(std::unordered_map<std::string, std::string> optionsMap) { reset(optionsMap); }
42-
void init(std::unordered_map<std::string, std::string> optionsMap) { reset(optionsMap); }
43-
void reset(std::unordered_map<std::string, std::string>);
49+
OrtModel(std::unordered_map<std::string, std::string> optionsMap) { init(optionsMap); }
50+
void init(std::unordered_map<std::string, std::string> optionsMap)
51+
{
52+
initOptions(optionsMap);
53+
initEnvironment();
54+
}
55+
virtual ~OrtModel() = default;
56+
57+
// General purpose
58+
void initOptions(std::unordered_map<std::string, std::string> optionsMap);
59+
void initEnvironment();
60+
void initSession();
61+
void memoryOnDevice(int32_t = 0);
4462
bool isInitialized() { return mInitialized; }
63+
void resetSession();
4564

46-
virtual ~OrtModel() = default;
65+
// Getters
66+
std::vector<std::vector<int64_t>> getNumInputNodes() const { return mInputShapes; }
67+
std::vector<std::vector<int64_t>> getNumOutputNodes() const { return mOutputShapes; }
68+
std::vector<std::string> getInputNames() const { return mInputNames; }
69+
std::vector<std::string> getOutputNames() const { return mOutputNames; }
70+
Ort::SessionOptions* getSessionOptions();
71+
Ort::MemoryInfo* getMemoryInfo();
72+
Ort::Env* getEnv();
73+
int32_t getIntraOpNumThreads() const { return intraOpNumThreads; }
74+
int32_t getInterOpNumThreads() const { return interOpNumThreads; }
75+
76+
// Setters
77+
void setDeviceId(int32_t id) { deviceId = id; }
78+
void setIO();
79+
void setActiveThreads(int threads) { intraOpNumThreads = threads; }
80+
void setIntraOpNumThreads(int threads)
81+
{
82+
if (deviceType == "CPU") {
83+
intraOpNumThreads = threads;
84+
}
85+
}
86+
void setInterOpNumThreads(int threads)
87+
{
88+
if (deviceType == "CPU") {
89+
interOpNumThreads = threads;
90+
}
91+
}
92+
void setEnv(Ort::Env*);
4793

4894
// Conversion
4995
template <class I, class O>
@@ -53,41 +99,36 @@ class OrtModel
5399
template <class I, class O> // class I is the input data type, e.g. float, class O is the output data type, e.g. OrtDataType::Float16_t from O2/Common/ML/include/ML/GPUORTFloat16.h
54100
std::vector<O> inference(std::vector<I>&);
55101

56-
template <class I, class O> // class I is the input data type, e.g. float, class O is the output data type, e.g. O2::gpu::OrtDataType::Float16_t from O2/GPU/GPUTracking/ML/convert_float16.h
102+
template <class I, class O>
57103
std::vector<O> inference(std::vector<std::vector<I>>&);
58104

59-
template <class I, class O> // class I is the input data type, e.g. float, class O is the output data type, e.g. OrtDataType::Float16_t from O2/Common/ML/include/ML/GPUORTFloat16.h
60-
void inference(I*, size_t, O*);
61-
62-
// template<class I, class T, class O> // class I is the input data type, e.g. float, class T the throughput data type and class O is the output data type
63-
// std::vector<O> inference(std::vector<I>&);
64-
65-
// Reset session
66-
void resetSession();
105+
template <class I, class O>
106+
void inference(I*, int64_t, O*);
67107

68-
std::vector<std::vector<int64_t>> getNumInputNodes() const { return mInputShapes; }
69-
std::vector<std::vector<int64_t>> getNumOutputNodes() const { return mOutputShapes; }
70-
std::vector<std::string> getInputNames() const { return mInputNames; }
71-
std::vector<std::string> getOutputNames() const { return mOutputNames; }
108+
template <class I, class O>
109+
void inference(I**, int64_t, O*);
72110

73-
void setActiveThreads(int threads) { intraOpNumThreads = threads; }
111+
void release(bool = false);
74112

75113
private:
76-
// ORT variables -> need to be hidden as Pimpl
114+
// ORT variables -> need to be hidden as pImpl
77115
struct OrtVariables;
78116
OrtVariables* pImplOrt;
79117

80118
// Input & Output specifications of the loaded network
81119
std::vector<const char*> inputNamesChar, outputNamesChar;
82120
std::vector<std::string> mInputNames, mOutputNames;
83-
std::vector<std::vector<int64_t>> mInputShapes, mOutputShapes;
121+
std::vector<std::vector<int64_t>> mInputShapes, mOutputShapes, inputShapesCopy, outputShapesCopy; // Input shapes
122+
std::vector<int64_t> inputSizePerNode, outputSizePerNode; // Output shapes
123+
int32_t mInputsTotal = 0, mOutputsTotal = 0; // Total number of inputs and outputs
84124

85125
// Environment settings
86126
bool mInitialized = false;
87-
std::string modelPath, device = "cpu", dtype = "float", thread_affinity = ""; // device options should be cpu, rocm, migraphx, cuda
88-
int intraOpNumThreads = 1, interOpNumThreads = 1, deviceId = 0, enableProfiling = 0, loggingLevel = 0, allocateDeviceMemory = 0, enableOptimizations = 0;
127+
std::string modelPath, envName = "", deviceType = "CPU", thread_affinity = ""; // device options should be cpu, rocm, migraphx, cuda
128+
int32_t intraOpNumThreads = 1, interOpNumThreads = 1, deviceId = -1, enableProfiling = 0, loggingLevel = 0, allocateDeviceMemory = 0, enableOptimizations = 0;
89129

90130
std::string printShape(const std::vector<int64_t>&);
131+
std::string printShape(const std::vector<std::vector<int64_t>>&, std::vector<std::string>&);
91132
};
92133

93134
} // namespace ml

0 commit comments

Comments
 (0)