ATLAS Offline Software
EvaluateModel.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #ifndef ATHEXONNXRUNTIME_EVALUATEMODEL_H
4 #define ATHEXONNXRUNTIME_EVALUATEMODEL_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 <memory>
18 #include <string>
19 #include <vector>
20 
21 namespace AthOnnx {
22 
31 
32  public:
35 
38 
40  virtual StatusCode initialize() override;
42  virtual StatusCode execute( const EventContext& ctx ) const override;
44  virtual StatusCode finalize() override;
45 
47 
48  private:
51 
53  Gaudi::Property< std::string > m_pixelFileName{ this, "InputDataPixel",
54  "dev/MLTest/2020-03-31/t10k-images-idx3-ubyte",
55  "Name of the input pixel file to load" };
56 
58  Gaudi::Property<int> m_batchSize {this, "BatchSize", 1, "No. of elements/example in a batch"};
59 
61  ToolHandle< IOnnxRuntimeInferenceTool > m_onnxTool{
62  this, "ORTInferenceTool", "AthOnnx::OnnxRuntimeInferenceTool"
63  };
64 
65  std::vector<std::vector<std::vector<float>>> m_input_tensor_values_notFlat;
66 
67  }; // class EvaluateModel
68 
69 } // namespace AthOnnx
70 
71 #endif // ATHEXONNXRUNTIME_EVALUATEMODEL_H
AthOnnx::EvaluateModel::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition: EvaluateModel.cxx:70
IOnnxRuntimeInferenceTool.h
AthOnnx::EvaluateModel::finalize
virtual StatusCode finalize() override
Function finalising the algorithm.
Definition: EvaluateModel.cxx:136
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AthReentrantAlgorithm::AthReentrantAlgorithm
AthReentrantAlgorithm()
Default constructor:
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthOnnx::EvaluateModel::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm for a single event.
Definition: EvaluateModel.cxx:92
AthOnnx::EvaluateModel
Algorithm demonstrating the usage of the ONNX Runtime C++ API.
Definition: EvaluateModel.h:30
AthReentrantAlgorithm.h
AthOnnx::EvaluateModel::m_onnxTool
ToolHandle< IOnnxRuntimeInferenceTool > m_onnxTool
Tool handler for onnx inference session.
Definition: EvaluateModel.h:61
AthOnnx::EvaluateModel::m_batchSize
Gaudi::Property< int > m_batchSize
Following properties needed to be consdered if the .onnx model is evaluated in batch mode.
Definition: EvaluateModel.h:58
AthOnnx::EvaluateModel::m_pixelFileName
Gaudi::Property< std::string > m_pixelFileName
Name of the model file to load.
Definition: EvaluateModel.h:53
AthOnnx::EvaluateModel::m_input_tensor_values_notFlat
std::vector< std::vector< std::vector< float > > > m_input_tensor_values_notFlat
Definition: EvaluateModel.h:65
AthOnnx
Namespace holding all of the Onnx Runtime example code.
Definition: EvaluateModel.cxx:13