ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthOnnx
AthOnnxComps
src
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).
4
#include "
AthOnnxComps/OnnxRuntimeSvc.h
"
5
#include <onnxruntime_c_api.h>
6
7
namespace
AthOnnx
{
8
OnnxRuntimeSvc::OnnxRuntimeSvc
(
const
std::string& name, ISvcLocator* svc) :
9
base_class(name, svc)
10
{
11
}
12
13
StatusCode
OnnxRuntimeSvc::initialize
() {
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,
static_cast<
OrtLoggingLevel
>
(
m_logLevel
.value()), name().c_str());
22
ATH_MSG_DEBUG
(
"Ort::Env object created"
);
23
24
// Return gracefully.
25
return
StatusCode::SUCCESS;
26
}
27
28
StatusCode
OnnxRuntimeSvc::finalize
() {
29
30
// Delete 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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
OnnxRuntimeSvc.h
AthOnnx::OnnxRuntimeSvc::m_logLevel
Gaudi::Property< int > m_logLevel
ONNX Runtime logging level (0=VERBOSE, 1=INFO, 2=WARNING, 3=ERROR, 4=FATAL).
Definition
OnnxRuntimeSvc.h:53
AthOnnx::OnnxRuntimeSvc::m_env
std::unique_ptr< Ort::Env > m_env
Global runtime environment for Onnx Runtime.
Definition
OnnxRuntimeSvc.h:56
AthOnnx::OnnxRuntimeSvc::env
virtual Ort::Env & env() const override
Return the Onnx Runtime environment object.
Definition
OnnxRuntimeSvc.cxx:38
AthOnnx::OnnxRuntimeSvc::finalize
virtual StatusCode finalize() override
Function finalising the service.
Definition
OnnxRuntimeSvc.cxx:28
AthOnnx::OnnxRuntimeSvc::initialize
virtual StatusCode initialize() override
Function initialising the service.
Definition
OnnxRuntimeSvc.cxx:13
AthOnnx::OnnxRuntimeSvc::OnnxRuntimeSvc
OnnxRuntimeSvc(const std::string &name, ISvcLocator *svc)
Definition
OnnxRuntimeSvc.cxx:8
AthOnnx
Namespace holding all of the Onnx Runtime example code.
Definition
EvaluateModel.cxx:11
Generated on
for ATLAS Offline Software by
1.17.0