v2.0.0
Loading...
Searching...
No Matches
ml_onnx_model.h
Go to the documentation of this file.
1//=============================================================================================================
30
31#ifndef ML_ONNX_MODEL_H
32#define ML_ONNX_MODEL_H
33
34//=============================================================================================================
35// INCLUDES
36//=============================================================================================================
37
38#include "ml_global.h"
39#include "ml_model.h"
40
41//=============================================================================================================
42// QT INCLUDES
43//=============================================================================================================
44
45#include <QString>
46
47//=============================================================================================================
48// STL INCLUDES
49//=============================================================================================================
50
51#include <memory>
52#include <string>
53#include <vector>
54
55//=============================================================================================================
56// FORWARD DECLARE ORT TYPES
57//=============================================================================================================
58
59#ifdef MNE_USE_ONNXRUNTIME
60namespace Ort
61{
62class Env;
63class Session;
64class MemoryInfo;
65class RunOptions;
66}
67#endif
68
69//=============================================================================================================
70// DEFINE NAMESPACE MLLIB
71//=============================================================================================================
72
73namespace MLLIB
74{
75
76//=============================================================================================================
89{
90public:
91 //=========================================================================================================
96
97 //=========================================================================================================
101 ~MlOnnxModel() override;
102
103 //=========================================================================================================
104 MlTensor predict(const MlTensor& input) const override;
105 bool save(const QString& path) const override;
106 bool load(const QString& path) override;
107 QString modelType() const override;
108 MlTaskType taskType() const override;
109
110 //=========================================================================================================
114 bool isLoaded() const;
115
116 //=========================================================================================================
121 QString metadata(const QString& key) const;
122
123private:
124#ifdef MNE_USE_ONNXRUNTIME
125 static Ort::Env& ortEnv();
126#endif
127
128 QString m_modelPath;
130
131#ifdef MNE_USE_ONNXRUNTIME
132 std::unique_ptr<Ort::Session> m_session;
133 std::unique_ptr<Ort::MemoryInfo> m_memoryInfo;
134 std::vector<std::string> m_inputNames;
135 std::vector<std::string> m_outputNames;
136 std::vector<std::vector<int64_t>> m_inputShapes;
137#endif
138};
139
140} // namespace MLLIB
141
142#endif // ML_ONNX_MODEL_H
Pure-virtual MLLIB::MlModel interface that every MLLIB inference backend implements.
Export/import macros, build-stamp accessors and namespace anchor for the MLLIB machine-learning libra...
#define MLSHARED_EXPORT
Definition ml_global.h:48
Tensors, model abstraction, ONNX Runtime inference and Python training drivers used across mne-cpp.
MlTaskType
Definition ml_types.h:62
Backend-agnostic inference interface: load, predict, save plus model/task descriptors.
Definition ml_model.h:61
MlTaskType taskType() const override
QString metadata(const QString &key) const
bool load(const QString &path) override
QString modelType() const override
MlTensor predict(const MlTensor &input) const override
bool save(const QString &path) const override
N-dimensional row-major float32 tensor with shared-buffer storage, Eigen Map accessors and a non-owni...
Definition ml_tensor.h:76