ATLAS Offline Software
Loading...
Searching...
No Matches
OnnxRuntimeSvc.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3// Local include(s).
5#include <onnxruntime_c_api.h>
6
7namespace AthOnnx {
8 OnnxRuntimeSvc::OnnxRuntimeSvc(const std::string& name, ISvcLocator* svc) :
9 base_class(name, svc)
10 {
11 }
12
14
15 // Create the environment object.
16 Ort::ThreadingOptions tp_options;
17 tp_options.SetGlobalIntraOpNumThreads(1);
18 tp_options.SetGlobalInterOpNumThreads(1);
19
20 m_env = std::make_unique< Ort::Env >(
21 tp_options, ORT_LOGGING_LEVEL_WARNING, name().c_str());
22 ATH_MSG_DEBUG( "Ort::Env object created" );
23
24 // Return gracefully.
25 return StatusCode::SUCCESS;
26 }
27
29
30 // Dekete the environment object.
31 m_env.reset();
32 ATH_MSG_DEBUG( "Ort::Env object deleted" );
33
34 // Return gracefully.
35 return StatusCode::SUCCESS;
36 }
37
38 Ort::Env& OnnxRuntimeSvc::env() const {
39
40 return *m_env;
41 }
42
43} // namespace AthOnnx
#define ATH_MSG_DEBUG(x)
std::unique_ptr< Ort::Env > m_env
Global runtime environment for Onnx Runtime.
virtual Ort::Env & env() const override
Return the Onnx Runtime environment object.
virtual StatusCode finalize() override
Function finalising the service.
virtual StatusCode initialize() override
Function initialising the service.
OnnxRuntimeSvc(const std::string &name, ISvcLocator *svc)
Namespace holding all of the Onnx Runtime example code.