v2.0.0
Loading...
Searching...
No Matches
MLLIB::MlOnnxModel Class Reference

MlModel backend that runs .onnx graphs through ONNX Runtime with a cached CPU session. More...

#include <ml_onnx_model.h>

Public Member Functions

 MlOnnxModel ()
 ~MlOnnxModel () override
MlTensor predict (const MlTensor &input) const override
bool save (const QString &path) const override
bool load (const QString &path) override
QString modelType () const override
MlTaskType taskType () const override
bool isLoaded () const
QString metadata (const QString &key) const
Public Member Functions inherited from MLLIB::MlModel
virtual ~MlModel ()=default

Additional Inherited Members

Public Types inherited from MLLIB::MlModel
typedef QSharedPointer< MlModel > SPtr

Detailed Description

MlModel backend that runs .onnx graphs through ONNX Runtime with a cached CPU session.

When mne-cpp is configured without USE_ONNXRUNTIME every method either throws std::runtime_error (predict) or returns false / logs a warning (load, save), so the same client code compiles and links on minimal builds and on WebAssembly without conditional call sites.

Definition at line 88 of file ml_onnx_model.h.

Inheritance diagram for MLLIB::MlOnnxModel:
Inheritance graph

Constructor & Destructor Documentation

◆ MlOnnxModel()

MlOnnxModel::MlOnnxModel ( )

Default constructor.

Definition at line 77 of file ml_onnx_model.cpp.

◆ ~MlOnnxModel()

MlOnnxModel::~MlOnnxModel ( )
override

Destructor.

Definition at line 83 of file ml_onnx_model.cpp.

Member Function Documentation

◆ isLoaded()

bool MlOnnxModel::isLoaded ( ) const
Returns
True if an ONNX Runtime session has been loaded and is ready for inference.

Definition at line 221 of file ml_onnx_model.cpp.

◆ load()

bool MlOnnxModel::load ( const QString & path)
overridevirtual

Load a model from disk.

Parameters
[in]pathFile path.
Returns
True if successful.

Implements MLLIB::MlModel.

Definition at line 151 of file ml_onnx_model.cpp.

◆ metadata()

QString MlOnnxModel::metadata ( const QString & key) const
Parameters
[in]keyCustom metadata key stored in the model file.
Returns
The value stored under key, or an empty string if the model has none or is not loaded.

Definition at line 232 of file ml_onnx_model.cpp.

◆ modelType()

QString MlOnnxModel::modelType ( ) const
overridevirtual
Returns
Human-readable model type name.

Implements MLLIB::MlModel.

Definition at line 248 of file ml_onnx_model.cpp.

◆ predict()

MlTensor MlOnnxModel::predict ( const MlTensor & input) const
overridevirtual

Run inference on the given input tensor.

Parameters
[in]inputThe input data.
Returns
The prediction result.

Implements MLLIB::MlModel.

Definition at line 90 of file ml_onnx_model.cpp.

◆ save()

bool MlOnnxModel::save ( const QString & path) const
overridevirtual

Serialise the model to disk.

Parameters
[in]pathFile path.
Returns
True if successful.

Implements MLLIB::MlModel.

Definition at line 142 of file ml_onnx_model.cpp.

◆ taskType()

MlTaskType MlOnnxModel::taskType ( ) const
overridevirtual
Returns
The task type this model is configured for.

Implements MLLIB::MlModel.

Definition at line 255 of file ml_onnx_model.cpp.


The documentation for this class was generated from the following files: