|
| virtual tl::expected< std::vector< Tensor >, NeuralError > | infer (const Tensor &input)=0 |
| | Perform inference on the given input tensor.
|
| |
| tl::expected< std::vector< Tensor >, NeuralError > | operator() (const Tensor &input) |
| | Call the infer method with the given input tensor.
|
| |
| virtual size_t | inputCount () const =0 |
| | Get the number of inputs of the neural network.
|
| |
| virtual size_t | outputCount () const =0 |
| | Get the number of outputs of the neural network.
|
| |
| virtual Shape | inputShape (size_t idx=0) const =0 |
| | Get the input shape of the neural network. This might contain dynamic dimensions (e.g., -1 for batch size).
|
| |
| virtual Shape | outputShape (size_t idx=0) const =0 |
| | Get the output shape of the neural network. This might contain dynamic dimensions (e.g., -1 for batch size).
|
| |
| virtual std::string | inputName (size_t idx=0) const =0 |
| | Get the name of the input tensor.
|
| |
| virtual std::string | outputName (size_t idx=0) const =0 |
| | Get the name of the output tensor.
|
| |
| virtual int | gpuId () const =0 |
| | Get the GPU ID used by the neural network if it is configured to use GPU.
|
| |
Abstract base class for neural networks.
This class defines the interface for neural networks, including methods for inference, input/output shape queries, and operator overloading for convenience.
- See also
- NeuralNetPtr for a smart pointer alias to this class.
Perform inference on the given input tensor.
- Parameters
-
| input | The input tensor to the neural network. This tensor must have the correct shape and data type expected by the model. |
- Returns
- tl::expected<std::vector<Tensor>, NeuralError> The output tensors or an error object.
This method takes an input tensor, processes it through the neural network, and returns the output tensors. The input tensor must match the expected input shape of the model. If the input tensor is invalid or the inference fails, an error object is returned.
Implemented in NN::OrtNeuralNet.