ATLAS Offline Software
EvaluateModelWithAthInfer.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #ifndef ATHEXONNXRUNTIME_EVALUATEMODELWithAthInfer_H
4 #define ATHEXONNXRUNTIME_EVALUATEMODELWithAthInfer_H
5 
6 // Local include(s).
8 
9 // Framework include(s).
11 #include "GaudiKernel/ServiceHandle.h"
12 
13 // Onnx Runtime include(s).
14 #include <onnxruntime_cxx_api.h>
15 
16 // System include(s).
17 #include <string>
18 #include <vector>
19 
20 namespace AthOnnx {
21 
30 
31  public:
34 
37 
39  virtual StatusCode initialize() override;
41  virtual StatusCode execute( const EventContext& ctx ) const override;
42 
44 
45  private:
48 
50  Gaudi::Property< std::string > m_pixelFileName{ this, "InputDataPixel",
51  "dev/MLTest/2020-03-31/t10k-images-idx3-ubyte",
52  "Name of the input pixel file to load" };
53 
55  Gaudi::Property<int> m_batchSize {this, "BatchSize", 1, "No. of elements/example in a batch"};
56 
58  ToolHandle< AthInfer::IAthInferenceTool > m_onnxTool{
59  this, "ORTInferenceTool", "AthOnnx::OnnxRuntimeInferenceTool"
60  };
61 
62  std::vector<std::vector<std::vector<float>>> m_input_tensor_values_notFlat;
63 
64  }; // class EvaluateModel
65 
66 } // namespace AthOnnx
67 
68 #endif // ATHEXONNXRUNTIME_EVALUATEMODEL_H
AthOnnx::EvaluateModelWithAthInfer::m_onnxTool
ToolHandle< AthInfer::IAthInferenceTool > m_onnxTool
Tool handler for onnx inference session.
Definition: EvaluateModelWithAthInfer.h:58
AthOnnx::EvaluateModelWithAthInfer::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm for a single event.
Definition: EvaluateModelWithAthInfer.cxx:31
AthOnnx::EvaluateModelWithAthInfer::m_batchSize
Gaudi::Property< int > m_batchSize
Following properties needed to be consdered if the .onnx model is evaluated in batch mode.
Definition: EvaluateModelWithAthInfer.h:55
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AthOnnx::EvaluateModelWithAthInfer::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition: EvaluateModelWithAthInfer.cxx:13
AthReentrantAlgorithm::AthReentrantAlgorithm
AthReentrantAlgorithm()
Default constructor:
AthOnnx::EvaluateModelWithAthInfer::m_input_tensor_values_notFlat
std::vector< std::vector< std::vector< float > > > m_input_tensor_values_notFlat
Definition: EvaluateModelWithAthInfer.h:62
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IAthInferenceTool.h
AthOnnx::EvaluateModelWithAthInfer::m_pixelFileName
Gaudi::Property< std::string > m_pixelFileName
Name of the model file to load.
Definition: EvaluateModelWithAthInfer.h:50
AthReentrantAlgorithm.h
AthOnnx::EvaluateModelWithAthInfer
Algorithm demonstrating the usage of the ONNX Runtime C++ API.
Definition: EvaluateModelWithAthInfer.h:29
AthOnnx
Namespace holding all of the Onnx Runtime example code.
Definition: EvaluateModel.cxx:11