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{
35 class OPENMS_DLLAPI ONNXPredictorBase
36 {
37 public:
41 explicit ONNXPredictorBase(const std::string& model_path, int intra_op_threads = 4);
42
44
47
49 ONNXPredictorBase& operator=(ONNXPredictorBase&&) noexcept;
50
52 Ort::Session& session();
53 const Ort::Session& session() const;
54
56 Ort::MemoryInfo& memoryInfo();
57 const Ort::MemoryInfo& memoryInfo() const;
58
60 std::vector<std::string> getInputNames() const;
61
63 std::vector<std::string> getOutputNames() const;
64
66 std::vector<int64_t> getInputShape(size_t input_index) const;
67
69 size_t getInputCount() const;
70
72 size_t getOutputCount() const;
73
74 private:
75 std::unique_ptr<Ort::SessionOptions> session_options_;
76 std::unique_ptr<Ort::Session> session_;
77 std::unique_ptr<Ort::MemoryInfo> memory_info_;
78 };
79} // namespace OpenMS
Owns the ONNX Runtime session of one model file, for the predictors built on it.
Definition ONNXPredictorBase.h:36
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.