ML functions
 
Loading...
Searching...
No Matches
TorchDNNV2 Class Reference

A class that implements a configurable deep neural network using PyTorch, inheriting from MLFunction. More...

#include <functions.h>

Inheritance diagram for TorchDNNV2:
MLFunction

Public Member Functions

 TorchDNNV2 (std::vector< velox::dl::KernelType > kernelTypes, std::vector< float * > weights, std::vector< int > dimensions)
 Constructor that initializes the neural network with kernel types, weights, and dimensions.
 
void apply (const SelectivityVector &rows, std::vector< VectorPtr > &args, const TypePtr &type, exec::EvalCtx &context, VectorPtr &output) const override
 Applies the neural network to the input array.
 
float * getTensor () const override
 Returns the tensor associated with this function.
 
const std::vector< float * > & getWeights () const
 Returns the weights of the neural network.
 
const std::vector< float * > & getBias () const
 Returns the biases of the neural network.
 
std::string getFuncName ()
 Returns the name of the function.
 
std::vector< velox::dl::KernelTypegetKernelTypes () const
 Returns the kernel types used in the neural network.
 
CostEstimate getCost (std::vector< int > inputDims)
 Estimates the computational cost of applying the neural network.
 
- Public Member Functions inherited from MLFunction
virtual ~MLFunction ()=default
 Virtual destructor.
 
virtual std::vector< int > getDims ()
 Returns the dimensions of the function.
 
virtual int getNumDims ()
 Returns the number of dimensions of the function.
 

Static Public Member Functions

static std::vector< std::shared_ptr< exec::FunctionSignature > > signatures ()
 Returns the function signatures supported by this class.
 
static std::string getName ()
 Static method to return the name of the function.
 

Additional Inherited Members

- Protected Member Functions inherited from MLFunction
double getWeightedCost (std::string name, float cost)
 Calculates the weighted cost of the function.
 
std::vector< double > getCoefficientVector (std::string name)
 Retrieves the cost coefficients for the function.
 
- Protected Attributes inherited from MLFunction
std::vector< int > dims
 Dimensions of the function.
 

Detailed Description

A class that implements a configurable deep neural network using PyTorch, inheriting from MLFunction.

This class provides functionality to apply a neural network with configurable layers (e.g., MatMul, ReLU, Softmax, etc.).

Constructor & Destructor Documentation

◆ TorchDNNV2()

TorchDNNV2::TorchDNNV2 ( std::vector< velox::dl::KernelType > kernelTypes,
std::vector< float * > weights,
std::vector< int > dimensions )
inline

Constructor that initializes the neural network with kernel types, weights, and dimensions.

Parameters
kernelTypesA vector of KernelType specifying the types of layers in the network.
weightsA vector of pointers to weight matrices for each layer.
dimensionsA vector containing the dimensions of the neural network layers.

Member Function Documentation

◆ apply()

void TorchDNNV2::apply ( const SelectivityVector & rows,
std::vector< VectorPtr > & args,
const TypePtr & type,
exec::EvalCtx & context,
VectorPtr & output ) const
inlineoverride

Applies the neural network to the input array.

This method processes the input array, applies the neural network, and stores the result in the output vector.

Parameters
rowsA SelectivityVector specifying the rows to process.
argsA vector of input arguments (e.g., the input array).
typeThe type of the output vector.
contextThe execution context.
outputThe output vector where the result will be stored.

◆ getBias()

const std::vector< float * > & TorchDNNV2::getBias ( ) const
inline

Returns the biases of the neural network.

Returns
A vector of pointers to bias vectors.

◆ getCost()

CostEstimate TorchDNNV2::getCost ( std::vector< int > inputDims)
inlinevirtual

Estimates the computational cost of applying the neural network.

Parameters
inputDimsA vector containing the dimensions of the input.
Returns
A CostEstimate object representing the estimated cost.

Reimplemented from MLFunction.

◆ getFuncName()

std::string TorchDNNV2::getFuncName ( )
inlinevirtual

Returns the name of the function.

Returns
The name of the function as a string.

Reimplemented from MLFunction.

◆ getKernelTypes()

std::vector< velox::dl::KernelType > TorchDNNV2::getKernelTypes ( ) const
inline

Returns the kernel types used in the neural network.

Returns
A vector of KernelType specifying the types of layers.

◆ getName()

static std::string TorchDNNV2::getName ( )
inlinestatic

Static method to return the name of the function.

Returns
The name of the function as a string ("complexTorchNN").

◆ getTensor()

float * TorchDNNV2::getTensor ( ) const
inlineoverridevirtual

Returns the tensor associated with this function.

Returns
A pointer to an empty float array (no weights for TorchDNNV2).

Implements MLFunction.

◆ getWeights()

const std::vector< float * > & TorchDNNV2::getWeights ( ) const
inline

Returns the weights of the neural network.

Returns
A vector of pointers to weight matrices.

◆ signatures()

static std::vector< std::shared_ptr< exec::FunctionSignature > > TorchDNNV2::signatures ( )
inlinestatic

Returns the function signatures supported by this class.

Returns
A vector of shared pointers to FunctionSignature objects.

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