ATLAS Offline Software
ExampleMLInferenceWithTriton.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 #pragma once
4 
5 // Framework include(s).
8 
9 // System include(s).
10 #include <string>
11 #include <vector>
12 
13 namespace AthInfer {
14 
21 
22  public:
24  using AthReentrantAlgorithm::AthReentrantAlgorithm;
25 
28 
30  virtual StatusCode initialize() override;
32  virtual StatusCode execute( const EventContext& ctx ) const override;
33 
35 
36  private:
39 
41  Gaudi::Property< std::string > m_pixelFileName{ this, "InputDataPixel",
42  "dev/MLTest/2020-03-31/t10k-images-idx3-ubyte",
43  "Name of the input pixel file to load" };
44 
46  Gaudi::Property<int> m_batchSize {this, "BatchSize", 1, "No. of elements/example in a batch"};
47 
49  ToolHandle< AthInfer::IAthInferenceTool > m_tritonTool{
50  this, "InferenceTool", "AthInfer::TritonTool", "Triton client tool"
51  };
52 
53  std::vector<std::vector<std::vector<float>>> m_input_tensor_values_notFlat;
54 
55  private:
56  std::vector<std::vector<std::vector<float>>> read_mnist_pixel_notFlat(const std::string &full_path) const;
57  std::vector<float> flattenNestedVectors(const std::vector<std::vector<float>>& nestedVector) const;
58  };
59 
60 } // namespace AthInfer
AthInfer
Definition: ExampleMLInferenceWithTriton.cxx:12
AthInfer::ExampleMLInferenceWithTriton::m_input_tensor_values_notFlat
std::vector< std::vector< std::vector< float > > > m_input_tensor_values_notFlat
Definition: ExampleMLInferenceWithTriton.h:53
AthInfer::ExampleMLInferenceWithTriton::read_mnist_pixel_notFlat
std::vector< std::vector< std::vector< float > > > read_mnist_pixel_notFlat(const std::string &full_path) const
Definition: ExampleMLInferenceWithTriton.cxx:89
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
AthInfer::ExampleMLInferenceWithTriton::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm for a single event.
Definition: ExampleMLInferenceWithTriton.cxx:32
AthInfer::ExampleMLInferenceWithTriton::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition: ExampleMLInferenceWithTriton.cxx:14
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IAthInferenceTool.h
AthInfer::ExampleMLInferenceWithTriton::m_batchSize
Gaudi::Property< int > m_batchSize
Following properties needed to be consdered if the .onnx model is evaluated in batch mode.
Definition: ExampleMLInferenceWithTriton.h:46
AthReentrantAlgorithm.h
AthInfer::ExampleMLInferenceWithTriton::m_tritonTool
ToolHandle< AthInfer::IAthInferenceTool > m_tritonTool
Tool handle for the Triton client.
Definition: ExampleMLInferenceWithTriton.h:49
AthInfer::ExampleMLInferenceWithTriton
Algorithm demonstrating the usage of the Triton Client API.
Definition: ExampleMLInferenceWithTriton.h:20
AthInfer::ExampleMLInferenceWithTriton::flattenNestedVectors
std::vector< float > flattenNestedVectors(const std::vector< std::vector< float >> &nestedVector) const
AthInfer::ExampleMLInferenceWithTriton::m_pixelFileName
Gaudi::Property< std::string > m_pixelFileName
Name of the model file to load.
Definition: ExampleMLInferenceWithTriton.h:41