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

Class for performing matrix addition. More...

#include <functions.h>

Inheritance diagram for MatrixAddition:
MLFunction

Public Member Functions

 MatrixAddition (float *weights, int num_cols)
 Constructor for MatrixAddition.
 
 MatrixAddition (std::string weightsFile, int num_cols)
 Constructor for MatrixAddition.
 
void apply (const SelectivityVector &rows, std::vector< VectorPtr > &args, const TypePtr &type, exec::EvalCtx &context, VectorPtr &output) const override
 Apply the matrix addition operation.
 
float * getTensor () const override
 Get the tensor data associated with this function.
 
std::string getFuncName ()
 Get the name of the function.
 
std::string getWeightsFile ()
 Get the weights file associated with this function.
 
void setWeights (float *weights)
 Set the weights for this function.
 
CostEstimate getCost (std::vector< int > inputDims)
 Estimate the computational cost of 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.
 

Static Public Member Functions

static std::vector< std::shared_ptr< exec::FunctionSignature > > signatures ()
 Get the function signatures for matrix addition.
 
static std::string getName ()
 Get 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

Class for performing matrix addition.

This class implements matrix addition, which adds two matrices element-wise. It supports both in-place addition and addition with a weight matrix.

Constructor & Destructor Documentation

◆ MatrixAddition() [1/2]

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

Constructor for MatrixAddition.

Parameters
weightsA pointer to the weight matrix.
num_colsThe number of columns in the matrix.

◆ MatrixAddition() [2/2]

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

Constructor for MatrixAddition.

Parameters
weightsFileThe file containing the weight matrix.
num_colsThe number of columns in the matrix.

Member Function Documentation

◆ apply()

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

Apply the matrix addition operation.

Parameters
rowsThe selectivity vector indicating which rows to process.
argsThe input arguments.
typeThe type of the output vector.
contextThe evaluation context.
outputThe output vector.

◆ getCost()

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

Estimate the computational cost of the function.

Parameters
inputDimsThe dimensions of the input data.
Returns
A CostEstimate object representing the estimated cost.

Reimplemented from MLFunction.

◆ getFuncName()

std::string MatrixAddition::getFuncName ( )
inlinevirtual

Get the name of the function.

Returns
A string representing the function name.

Reimplemented from MLFunction.

◆ getName()

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

Get the name of the function.

Returns
A string representing the function name.

◆ getTensor()

float * MatrixAddition::getTensor ( ) const
inlineoverridevirtual

Get the tensor data associated with this function.

Returns
A pointer to the tensor data.

Implements MLFunction.

◆ getWeightsFile()

std::string MatrixAddition::getWeightsFile ( )
inline

Get the weights file associated with this function.

Returns
A string representing the weights file path.

◆ setWeights()

void MatrixAddition::setWeights ( float * weights)
inline

Set the weights for this function.

Parameters
weightsA pointer to the weight matrix.

◆ signatures()

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

Get the function signatures for matrix addition.

Returns
A vector of function signatures.

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