A class that performs matrix-vector addition, inheriting from MLFunction.
More...
#include <functions.h>
|
| | 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.
|
| |
|
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 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.
|
| |
|
| 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.
|
| |
|
std::vector< int > | dims |
| | Dimensions of the function.
|
| |
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.
◆ MatrixVectorAddition() [1/2]
| MatrixVectorAddition::MatrixVectorAddition |
( |
float * | weights, |
|
|
int | num_cols ) |
|
inline |
Constructor that initializes the class with a raw array of weights.
- Parameters
-
| weights | A pointer to a float array containing the weights (vector values). |
| num_cols | The 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
-
| weightsFile | The path to the file containing the weights. |
| num_cols | The number of columns in the matrix (and size of the vector). |
◆ 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
-
| rows | A SelectivityVector specifying the rows to process. |
| args | A vector of input arguments (e.g., the input matrix). |
| type | The type of the output vector. |
| context | The execution context. |
| output | The 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
-
| weights | A 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: