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

Class for performing matrix multiplication. More...

#include <functions.h>

Inheritance diagram for MatrixMultiply:
MLFunction

Public Member Functions

 MatrixMultiply (float *weights, int num_rows, int num_cols)
 Constructor for MatrixMultiply.
 
 MatrixMultiply (std::string weightsFile, int num_rows, int num_cols)
 Constructor for MatrixMultiply.
 
void apply (const SelectivityVector &rows, std::vector< VectorPtr > &args, const TypePtr &outputType, exec::EvalCtx &context, VectorPtr &output) const override
 Apply the matrix multiplication 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 multiplication.
 
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 multiplication.

This class implements matrix multiplication and provides methods to apply the operation, retrieve tensor data, and estimate computational cost.

Constructor & Destructor Documentation

◆ MatrixMultiply() [1/2]

MatrixMultiply::MatrixMultiply ( float * weights,
int num_rows,
int num_cols )
inline

Constructor for MatrixMultiply.

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

◆ MatrixMultiply() [2/2]

MatrixMultiply::MatrixMultiply ( std::string weightsFile,
int num_rows,
int num_cols )
inline

Constructor for MatrixMultiply.

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

Member Function Documentation

◆ apply()

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

Apply the matrix multiplication operation.

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

◆ getCost()

CostEstimate MatrixMultiply::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 MatrixMultiply::getFuncName ( )
inlinevirtual

Get the name of the function.

Returns
A string representing the function name.

Reimplemented from MLFunction.

◆ getName()

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

Get the name of the function.

Returns
A string representing the function name.

◆ getTensor()

float * MatrixMultiply::getTensor ( ) const
inlineoverridevirtual

Get the tensor data associated with this function.

Returns
A pointer to the tensor data.

Implements MLFunction.

◆ getWeightsFile()

std::string MatrixMultiply::getWeightsFile ( )
inline

Get the weights file associated with this function.

Returns
A string representing the weights file path.

◆ setWeights()

void MatrixMultiply::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 > > MatrixMultiply::signatures ( )
inlinestatic

Get the function signatures for matrix multiplication.

Returns
A vector of function signatures.

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