OpenMS
Loading...
Searching...
No Matches
ONNXPredictorBase.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Satyam Yadav $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
12#include <cstddef>
13#include <cstdint>
14#include <string>
15#include <memory>
16#include <vector>
17
18// Forward declaration to avoid exposing ONNX headers globally
19namespace Ort {
20 struct Session;
21 struct SessionOptions;
22 struct MemoryInfo;
23}
24
25namespace OpenMS
26{
36 class OPENMS_DLLAPI ONNXPredictorBase
37 {
38 public:
42 explicit ONNXPredictorBase(const std::string& model_path, int intra_op_threads = 4);
43
45
48
50 ONNXPredictorBase& operator=(ONNXPredictorBase&&) noexcept;
51
53 Ort::Session& session();
54 const Ort::Session& session() const;
55
57 Ort::MemoryInfo& memoryInfo();
58 const Ort::MemoryInfo& memoryInfo() const;
59
61 std::vector<std::string> getInputNames() const;
62
64 std::vector<std::string> getOutputNames() const;
65
67 std::vector<int64_t> getInputShape(size_t input_index) const;
68
70 size_t getInputCount() const;
71
73 size_t getOutputCount() const;
74
75 private:
76 std::unique_ptr<Ort::SessionOptions> session_options_;
77 std::unique_ptr<Ort::Session> session_;
78 std::unique_ptr<Ort::MemoryInfo> memory_info_;
79 };
80} // namespace OpenMS
Owns the ONNX Runtime session of one model file, for the predictors built on it.
Definition ONNXPredictorBase.h:37
ONNXPredictorBase & operator=(const ONNXPredictorBase &)=delete
ONNXPredictorBase(const std::string &model_path, int intra_op_threads=4)
Constructor initializes the generic ONNX session safely across platforms.
ONNXPredictorBase(const ONNXPredictorBase &)=delete
ONNXPredictorBase(ONNXPredictorBase &&) noexcept
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition ONNXPredictorBase.h:19
STL namespace.