v2.0.0
Loading...
Searching...
No Matches
ml_onnx_model.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef ML_ONNX_MODEL_H
36#define ML_ONNX_MODEL_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "ml_global.h"
43#include "ml_model.h"
44
45//=============================================================================================================
46// QT INCLUDES
47//=============================================================================================================
48
49#include <QString>
50
51//=============================================================================================================
52// STL INCLUDES
53//=============================================================================================================
54
55#include <memory>
56#include <string>
57#include <vector>
58
59//=============================================================================================================
60// FORWARD DECLARE ORT TYPES
61//=============================================================================================================
62
63#ifdef MNE_USE_ONNXRUNTIME
64namespace Ort { class Env; class Session; class MemoryInfo; class RunOptions; }
65#endif
66
67//=============================================================================================================
68// DEFINE NAMESPACE MLLIB
69//=============================================================================================================
70
71namespace MLLIB{
72
73//=============================================================================================================
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
MlModel pure-abstract base class declaration.
ml library export/import macros.
#define MLSHARED_EXPORT
Definition ml_global.h:55
Machine learning (models, pipelines, ONNX Runtime integration).
MlTaskType
Definition ml_types.h:60
Abstract interface for all ML models.
Definition ml_model.h:64
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 tensor with contiguous row-major (C-order) float32 storage.
Definition ml_tensor.h:79