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 { class Env; class Session; class MemoryInfo; class RunOptions; }
61#endif
62
63//=============================================================================================================
64// DEFINE NAMESPACE MLLIB
65//=============================================================================================================
66
67namespace MLLIB{
68
69//=============================================================================================================
80{
81public:
82 //=========================================================================================================
87
88 //=========================================================================================================
92 ~MlOnnxModel() override;
93
94 //=========================================================================================================
95 MlTensor predict(const MlTensor& input) const override;
96 bool save(const QString& path) const override;
97 bool load(const QString& path) override;
98 QString modelType() const override;
99 MlTaskType taskType() const override;
100
101 //=========================================================================================================
105 bool isLoaded() const;
106
107private:
108#ifdef MNE_USE_ONNXRUNTIME
109 static Ort::Env& ortEnv();
110#endif
111
112 QString m_modelPath;
114
115#ifdef MNE_USE_ONNXRUNTIME
116 std::unique_ptr<Ort::Session> m_session;
117 std::unique_ptr<Ort::MemoryInfo> m_memoryInfo;
118 std::vector<std::string> m_inputNames;
119 std::vector<std::string> m_outputNames;
120 std::vector<std::vector<int64_t>> m_inputShapes;
121#endif
122};
123
124} // namespace MLLIB
125
126#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:51
Backend-agnostic inference interface: load, predict, save plus model/task descriptors.
Definition ml_model.h:58
MlTaskType taskType() const override
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:73