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

A class that performs matrix-vector addition, inheriting from MLFunction. More...

#include <functions.h>

Inheritance diagram for MatrixVectorAddition:
MLFunction

Public Member Functions

 MatrixVectorAddition (float *weights, int num_cols)
 Constructor that initializes the class with a raw array of weights.
 
 MatrixVectorAddition (std::string weightsFile, int num_cols)
 Constructor that initializes the class with a file containing weights.
 
void apply (const SelectivityVector &rows, std::vector< VectorPtr > &args, const TypePtr &type, exec::EvalCtx &context, VectorPtr &output) const override
 Applies the matrix-vector addition operation.
 
float * getTensor () const override
 Returns the tensor associated with this function.
 
float * getTensor () const override
 Returns the tensor (weights) associated with this function.
 
std::string getFuncName ()
 Returns the name of the function.
 
std::string getWeightsFile ()
 Returns the path to the weights file.
 
void setWeights (float *weights)
 Sets the weights for the function.
 
- 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.
 
virtual CostEstimate getCost (std::vector< int > inputDims)
 Estimates the computational cost of applying the function.
 

Static Public Member Functions

static std::vector< std::shared_ptr< exec::FunctionSignature > > signatures ()
 
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 performs matrix-vector addition, inheriting from MLFunction.

This class provides functionality to add a vector to each row of a matrix. It supports initialization with either a raw array of weights or a file containing weights. The apply method performs the matrix-vector addition operation and writes the result to the output vector.

Constructor & Destructor Documentation

◆ MatrixVectorAddition() [1/2]

MatrixVectorAddition::MatrixVectorAddition ( float * weights,
int num_cols )
inline

Constructor that initializes the class with a raw array of weights.

Parameters
weightsA pointer to a float array containing the weights (vector values).
num_colsThe number of columns in the matrix (and size of the vector).

◆ MatrixVectorAddition() [2/2]

MatrixVectorAddition::MatrixVectorAddition ( std::string weightsFile,
int num_cols )
inline

Constructor that initializes the class with a file containing weights.

Parameters
weightsFileThe path to the file containing the weights.
num_colsThe number of columns in the matrix (and size of the vector).

Member Function Documentation

◆ apply()

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

Applies the matrix-vector addition operation.

This method performs the matrix-vector addition for the selected rows 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 matrix).
typeThe type of the output vector.
contextThe execution context.
outputThe output vector where the result will be stored.

◆ getFuncName()

std::string MatrixVectorAddition::getFuncName ( )
inlinevirtual

Returns the name of the function.

Returns
The name of the function as a string.

Reimplemented from MLFunction.

◆ getName()

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

Static method to return the name of the function.

Returns
The name of the function as a string.

◆ getTensor() [1/2]

float * MatrixVectorAddition::getTensor ( ) const
inlineoverridevirtual

Returns the tensor associated with this function.

Returns
A pointer to the tensor data.

Implements MLFunction.

◆ getTensor() [2/2]

float * MatrixVectorAddition::getTensor ( ) const
inlineoverridevirtual

Returns the tensor (weights) associated with this function.

Returns
A pointer to the float array containing the weights.

Implements MLFunction.

◆ getWeightsFile()

std::string MatrixVectorAddition::getWeightsFile ( )
inline

Returns the path to the weights file.

Returns
The path to the weights file as a string.

◆ setWeights()

void MatrixVectorAddition::setWeights ( float * weights)
inline

Sets the weights for the function.

Parameters
weightsA pointer to a float array containing the new weights.

◆ signatures()

static std::vector< std::shared_ptr< exec::FunctionSignature > > MatrixVectorAddition::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: