ATLAS Offline Software
Loading...
Searching...
No Matches
EvaluateModelWithAsyncInfer.h
Go to the documentation of this file.
1// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3#ifndef ATHEXONNXRUNTIME_EVALUATEMODELWithAsyncInfer_H
4#define ATHEXONNXRUNTIME_EVALUATEMODELWithAsyncInfer_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 AthAsynchronousAlgorithm::AthAsynchronousAlgorithm;
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{
51 this, "InputDataPixel", "dev/MLTest/2020-03-31/t10k-images-idx3-ubyte",
52 "Name of the input pixel file to load"};
53
56 Gaudi::Property<int> m_batchSize{this, "BatchSize", 1,
57 "No. of elements/example in a batch"};
58
60 ToolHandle<AthInfer::IAthInferenceTool> m_onnxTool{
61 this, "ORTInferenceTool", "AthOnnx::OnnxRuntimeInferenceTool"};
62
63 std::vector<std::vector<std::vector<float>>> m_input_tensor_values_notFlat;
64
65}; // class EvaluateModel
66
67} // namespace AthOnnx
68
69#endif // ATHEXONNXRUNTIME_EVALUATEMODELWithAsyncInfer_H
An algorithm that can be suspended while work is offloaded to an accelerator.
Algorithm demonstrating the usage of the ONNX Runtime C++ API.
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm for a single event.
Gaudi::Property< std::string > m_pixelFileName
Name of the input file to load.
std::vector< std::vector< std::vector< float > > > m_input_tensor_values_notFlat
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.
ToolHandle< AthInfer::IAthInferenceTool > m_onnxTool
Tool handler for onnx inference session.
Namespace holding all of the Onnx Runtime example code.