iVS3D v2.0.0
Loading...
Searching...
No Matches
NN::NeuralNet Class Referenceabstract

Abstract base class for neural networks. More...

#include <NeuralNet.h>

Inheritance diagram for NN::NeuralNet:
NN::OrtNeuralNet

Public Member Functions

virtual tl::expected< Tensor, NeuralErrorinfer (const Tensor &input)=0
 Perform inference on the given input tensor.
 
tl::expected< Tensor, NeuralErroroperator() (const Tensor &input)
 Call the infer method with the given input tensor.
 
virtual Shape inputShape () const =0
 Get the input shape of the neural network. This might contain dynamic dimensions (e.g., -1 for batch size).
 
virtual Shape outputShape () const =0
 Get the output shape of the neural network. This might contain dynamic dimensions (e.g., -1 for batch size).
 
virtual int gpuId () const =0
 Get the GPU ID used by the neural network if it is configured to use GPU.
 

Detailed Description

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.

Member Function Documentation

◆ gpuId()

virtual int NN::NeuralNet::gpuId ( ) const
pure virtual

Get the GPU ID used by the neural network if it is configured to use GPU.

Returns
int The GPU ID, or -1 if the neural network does not use GPU.

This method returns the ID of the GPU that the neural network uses for inference. If the neural network is not using GPU, it returns -1.

Implemented in NN::OrtNeuralNet.

◆ infer()

virtual tl::expected< Tensor, NeuralError > NN::NeuralNet::infer ( const Tensor input)
pure virtual

Perform inference on the given input tensor.

Parameters
inputThe input tensor to the neural network. This tensor must have the correct shape and data type expected by the model.
Returns
tl::expected<Tensor, NeuralError> The output tensor or an error object.

This method takes an input tensor, processes it through the neural network, and returns the output tensor. 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.

◆ inputShape()

virtual Shape NN::NeuralNet::inputShape ( ) const
pure virtual

Get the input shape of the neural network. This might contain dynamic dimensions (e.g., -1 for batch size).

Returns
Shape The input shape of the neural network.

Implemented in NN::OrtNeuralNet.

◆ operator()()

tl::expected< Tensor, NeuralError > NN::NeuralNet::operator() ( const Tensor input)
inline

Call the infer method with the given input tensor.

Parameters
inputThe input tensor to the neural network.
Returns
tl::expected<Tensor, NeuralError> The output tensor or an error object.
See also
infer(const Tensor& input) for more details.

◆ outputShape()

virtual Shape NN::NeuralNet::outputShape ( ) const
pure virtual

Get the output shape of the neural network. This might contain dynamic dimensions (e.g., -1 for batch size).

Returns
Shape The output shape of the neural network.

Implemented in NN::OrtNeuralNet.


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