19 return StatusCode::FAILURE;
28 return StatusCode::SUCCESS;
32 const std::string& modelPath)
const {
35 if (resolvedPath.empty()) {
37 resolvedPath = modelPath;
42 Ort::SessionOptions sessionOptions;
43 sessionOptions.SetIntraOpNumThreads(1);
44 sessionOptions.SetGraphOptimizationLevel(ORT_ENABLE_ALL);
45 sessionOptions.DisablePerSessionThreads();
47 return std::make_unique<Ort::Session>(
m_onnxSvc->env(), resolvedPath.c_str(),
56 return StatusCode::SUCCESS;
59 auto collection = std::make_unique<OnnxNNCollection>();
64 }
catch (
const Ort::Exception& e) {
65 ATH_MSG_FATAL(
"Failed to load number network ONNX model: " << e.what());
66 return StatusCode::FAILURE;
70 const std::array<std::string, 3> posPaths = {
75 std::unique_ptr<Ort::Session>* posMembers[3] = {
76 &collection->positionNetwork1,
77 &collection->positionNetwork2,
78 &collection->positionNetwork3
81 for (
int i = 0; i < 3; ++i) {
82 if (posPaths[i].
empty()) {
83 ATH_MSG_DEBUG(
"Position network " << (i+1) <<
" path not set, skipping");
88 }
catch (
const Ort::Exception& e) {
90 <<
" ONNX model: " << e.what());
91 return StatusCode::FAILURE;
101 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
static const Attributes_t empty
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
Gaudi::Property< std::string > m_numberNetworkPath
std::unique_ptr< Ort::Session > createSession(const std::string &modelPath) const
Gaudi::Property< std::string > m_posNetwork1Path
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< OnnxNNCollection > m_writeKey
Gaudi::Property< std::string > m_posNetwork3Path
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_posNetwork2Path
ServiceHandle< AthOnnx::IOnnxRuntimeSvc > m_onnxSvc
static std::string find_calib_file(const std::string &logical_file_name)
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED