ATLAS Offline Software
Loading...
Searching...
No Matches
METNetHandler.h
Go to the documentation of this file.
2/*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
5// Author: Bill Balunas <balunas@cern.ch>, based on earlier implementation by M. Leigh
7
8#ifndef METUTILITIES_MET_METNETHANDLER_H
9#define METUTILITIES_MET_METNETHANDLER_H
10
11// STL includes
12#include <string>
13#include <mutex>
14
15// ONNX Library
16#include <onnxruntime_cxx_api.h>
17
18// For ATLAS_THREAD_SAFE
20
22
23namespace ADD_CMODE(met) {
24
25 class METNetHandler {
26
27 public:
28
29 // Constructor with parameters
30 METNetHandler(const std::string& modelName);
31
32 // Destructor
33 virtual ~METNetHandler() = default;
34
35 // Public methods
36 int initialize();
37 unsigned int getReqSize() const;
38 void predict(std::vector<float>& outputs, std::vector<float>& inputs) const;
39
40 private:
41
42 // Default constructor
43 METNetHandler() = delete;
44
45 // Class properties
46 std::string m_modelName; // Path to the onnx file
47 std::string m_modelPath; // Output of the path resolver
48
49 // Features of the network structure
50 size_t m_numInputs;
51 size_t m_numOutputs;
52 std::vector<int64_t> m_inputDims;
53 std::vector<int64_t> m_outputDims;
54 std::vector<const char *> m_graphInputNames;
55 std::vector<const char *> m_graphOutputNames;
56
57 // ONNX session objects
58 Ort::Env m_onnxEnv;
59 Ort::SessionOptions m_onnxSessionOptions;
60 Ort::AllocatorWithDefaultOptions m_onnxAllocator;
61 mutable std::unique_ptr<Ort::Session> m_onnxSession ATLAS_THREAD_SAFE {nullptr};
62 mutable std::mutex m_onnxMutex ATLAS_THREAD_SAFE;
63 };
64
65}
66
67#endif
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
void initialize()