class
#include <model.hpp>
Model A base class for machine learning models.
Contents
This class serves as a base class for machine learning models. It provides common functionality such as loading a model, accessing inputs and outputs, applying a delegate, and executing the model.
Derived classes
Constructors, destructors, conversion operators
Public functions
- auto operator=(const Model&) -> Model & defaulted
- auto operator=(Model&&) -> Model & deleted
- auto loadModel(const std::filesystem::path& modelPath) -> STATUS pure virtual
- Pure virtual function to load a model from a file path.
- auto loadModel(const nonstd::span<uint8_t>& modelBuffer) -> STATUS pure virtual
- Pure virtual function to load a model from a file buffer.
- auto getNumInputs() const -> size_t
- Get the number of input tensors in the model.
- auto getNumOutputs() const -> size_t
- Get the number of output tensors in the model.
- auto getInput(size_t index) const -> std::shared_ptr< Tensor >
- Get the input tensor at the specified index.
- auto getOutput(size_t index) const -> std::shared_ptr< Tensor >
- Get the output tensor at the specified index.
- auto getInputs() -> std::vector< std::shared_ptr< Tensor >> &
- Get the inputs of the model.
- auto getOutputs() -> std::vector< std::shared_ptr< Tensor >> &
- Get the outputs of the model.
- auto getDelegate() const -> DELEGATE
- Get the current delegate used for model execution.
- auto applyDelegate(const DELEGATE& delegate) -> STATUS pure virtual
- Apply a delegate for model execution.
- auto execute() -> STATUS pure virtual
- Execute the model.
- auto name() const -> const std::string &
- Get the name of the model.
- auto getCreationStatus() const -> STATUS
- Get the status of model creation.
- auto getPrecision() const -> TensorType
- Get the precision used for model execution.
Protected functions
- void setDelegate(const DELEGATE& delegate)
- Set the delegate for model execution.
- void setPrecision(const TensorType& precision)
- Set the precision for model execution.
- void setCreationStatus(const STATUS& status)
- Set the status of model creation.
Function documentation
auto edge:: Model:: loadModel(const std::filesystem::path& modelPath) -> STATUS pure virtual
Pure virtual function to load a model from a file path.
Parameters | |
---|---|
modelPath | The path to the model file |
Returns | STATUS The status of the model loading operation |
This function is a pure virtual function that must be implemented by any derived classes. It is used to load a model from a file path.
auto edge:: Model:: loadModel(const nonstd::span<uint8_t>& modelBuffer) -> STATUS pure virtual
Pure virtual function to load a model from a file buffer.
Parameters | |
---|---|
modelBuffer | The buffer containing the model |
Returns | STATUS The status of the model loading operation |
This function is a pure virtual function that must be implemented by any derived classes. It is used to load a model from a file buffer.
auto edge:: Model:: getNumInputs() const -> size_t
Get the number of input tensors in the model.
Returns | The number of input tensors |
---|
auto edge:: Model:: getNumOutputs() const -> size_t
Get the number of output tensors in the model.
Returns | The number of output tensors |
---|
auto edge:: Model:: getInput(size_t index) const -> std::shared_ptr< Tensor >
Get the input tensor at the specified index.
Parameters | |
---|---|
index | The index of the input tensor |
Returns | The input tensor at the specified index, or nullptr if index is out of bounds |
auto edge:: Model:: getOutput(size_t index) const -> std::shared_ptr< Tensor >
Get the output tensor at the specified index.
Parameters | |
---|---|
index | The index of the output tensor |
Returns | The output tensor at the specified index, or nullptr if index is out of bounds |
auto edge:: Model:: getInputs() -> std::vector< std::shared_ptr< Tensor >> &
Get the inputs of the model.
Returns | A reference to a vector of shared pointers to Tensor objects representing the inputs of the model. |
---|
This function returns a reference to a vector of shared pointers to Tensor objects, which represent the inputs of the model.
auto edge:: Model:: getOutputs() -> std::vector< std::shared_ptr< Tensor >> &
Get the outputs of the model.
Returns | A reference to a vector of shared pointers to Tensor objects representing the outputs of the model. |
---|
This function returns a reference to a vector of shared pointers to Tensor objects, which represent the outputs of the model.
auto edge:: Model:: getDelegate() const -> DELEGATE
Get the current delegate used for model execution.
Returns | The delegate currently set for model execution |
---|
auto edge:: Model:: applyDelegate(const DELEGATE& delegate) -> STATUS pure virtual
Apply a delegate for model execution.
Parameters | |
---|---|
delegate | The delegate to apply |
Returns | The status of the operation |
auto edge:: Model:: execute() -> STATUS pure virtual
Execute the model.
Returns | The status of the operation |
---|
auto edge:: Model:: name() const -> const std::string &
Get the name of the model.
Returns | The name of the model |
---|
auto edge:: Model:: getCreationStatus() const -> STATUS
Get the status of model creation.
Returns | The status of model creation |
---|
Verify that the model was created successfully
auto edge:: Model:: getPrecision() const -> TensorType
Get the precision used for model execution.
Returns | The pricsion used model execution |
---|
void edge:: Model:: setDelegate(const DELEGATE& delegate) protected
Set the delegate for model execution.
Parameters | |
---|---|
delegate | The delegate to set |
This method is used by derivatives to allow users to query the currently set delegate
void edge:: Model:: setPrecision(const TensorType& precision) protected
Set the precision for model execution.
This method is used by derivatives to allow users to query the execution precision
void edge:: Model:: setCreationStatus(const STATUS& status) protected
Set the status of model creation.
Parameters | |
---|---|
status | The status to set |
This method is used by derivatives to allow querying of model creation status