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

Implements an embedding layer for machine learning, where embeddings are stored as a 2-D array. More...

#include <Embedding.h>

Inheritance diagram for Embedding:
MLFunction

Public Member Functions

 Embedding (float *weights, int numEmbeddings, int embeddingDims)
 Constructor for Embedding.
 
 Embedding (std::string weightsFile, int numEmbeddings, int embeddingDims)
 Constructor for Embedding.
 
void apply (const SelectivityVector &rows, std::vector< VectorPtr > &args, const TypePtr &type, exec::EvalCtx &context, VectorPtr &output) const override
 Applies the embedding function to the input data.
 
float * getTensor () const override
 Returns the tensor associated with the function.
 
std::string getWeightsFile ()
 Returns the path to the weights file.
 
void setWeights (float *weights)
 Sets the embedding weights.
 
- Public Member Functions inherited from MLFunction
virtual ~MLFunction ()=default
 Virtual destructor.
 
virtual std::vector< int > getDims ()
 Returns the dimensions of the function.
 
virtual std::string getFuncName ()
 Returns the name 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 ()
 Returns the function signatures.
 
static std::string getName ()
 Returns 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

Implements an embedding layer for machine learning, where embeddings are stored as a 2-D array.

Constructor & Destructor Documentation

◆ Embedding() [1/2]

Embedding::Embedding ( float * weights,
int numEmbeddings,
int embeddingDims )
inline

Constructor for Embedding.

Parameters
weightsPointer to the embedding weights.
numEmbeddingsNumber of embeddings.
embeddingDimsDimensionality of each embedding.

◆ Embedding() [2/2]

Embedding::Embedding ( std::string weightsFile,
int numEmbeddings,
int embeddingDims )
inline

Constructor for Embedding.

Parameters
weightsFilePath to the file containing the embedding weights.
numEmbeddingsNumber of embeddings.
embeddingDimsDimensionality of each embedding.

Member Function Documentation

◆ apply()

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

Applies the embedding function to the input data.

Parameters
rowsSelectivity vector indicating which rows to process.
argsVector of input arguments.
typeType of the output vector.
contextEvaluation context.
outputOutput vector to store the results.

◆ getName()

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

Returns the name of the function.

Returns
Function name.

◆ getTensor()

float * Embedding::getTensor ( ) const
inlineoverridevirtual

Returns the tensor associated with the function.

Returns
Pointer to the tensor.

Implements MLFunction.

◆ getWeightsFile()

std::string Embedding::getWeightsFile ( )
inline

Returns the path to the weights file.

Returns
Path to the weights file.

◆ setWeights()

void Embedding::setWeights ( float * weights)
inline

Sets the embedding weights.

Parameters
weightsPointer to the embedding weights.

◆ signatures()

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

Returns the function signatures.

Returns
Vector of function signatures.

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