ATLAS Offline Software
Loading...
Searching...
No Matches
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
20namespace AthOnnx {
21
30
31 public:
33 using AthReentrantAlgorithm::AthReentrantAlgorithm;
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
Algorithm demonstrating the usage of the ONNX Runtime C++ API.
std::vector< std::vector< std::vector< float > > > m_input_tensor_values_notFlat
Gaudi::Property< std::string > m_pixelFileName
Name of the model file to load.
ToolHandle< AthInfer::IAthInferenceTool > m_onnxTool
Tool handler for onnx inference session.
Gaudi::Property< int > m_batchSize
Following properties needed to be consdered if the .onnx model is evaluated in batch mode.
virtual StatusCode initialize() override
Function initialising the algorithm.
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm for a single event.
An algorithm that can be simultaneously executed in multiple threads.
Namespace holding all of the Onnx Runtime example code.