ML functions
 
Loading...
Searching...
No Matches
BaseFunction.h
1
9class MLFunction : public exec::VectorFunction {
10public:
14 virtual ~MLFunction() = default;
15
21 virtual float* getTensor() const = 0;
22
28 virtual std::vector<int> getDims() {
29 return dims;
30 }
31
37 virtual std::string getFuncName() {
38 return "";
39 }
40
46 virtual int getNumDims() {
47 return dims.size();
48 }
49
56 virtual CostEstimate getCost(std::vector<int> inputDims) {
57 return CostEstimate(0, inputDims[0], inputDims[1]);
58 }
59
60protected:
61 std::vector<int> dims;
62
70 double getWeightedCost(std::string name, float cost) {
71 std::vector<double> coefficient =
72 UdfCostCoefficient::getInstance().getCoefficient(name);
73 // FIXME: Implement weighted cost calculation.
74 return 0;
75 }
76
83 std::vector<double> getCoefficientVector(std::string name) {
84 return UdfCostCoefficient::getInstance().getCoefficient(name);
85 }
86};
A base class for machine learning functions, inheriting from Velox's VectorFunction.
Definition BaseFunction.h:9
virtual float * getTensor() const =0
Returns the tensor associated with this function.
virtual std::vector< int > getDims()
Returns the dimensions of the function.
Definition BaseFunction.h:28
virtual CostEstimate getCost(std::vector< int > inputDims)
Estimates the computational cost of applying the function.
Definition BaseFunction.h:56
virtual std::string getFuncName()
Returns the name of the function.
Definition BaseFunction.h:37
double getWeightedCost(std::string name, float cost)
Calculates the weighted cost of the function.
Definition BaseFunction.h:70
virtual ~MLFunction()=default
Virtual destructor.
virtual int getNumDims()
Returns the number of dimensions of the function.
Definition BaseFunction.h:46
std::vector< double > getCoefficientVector(std::string name)
Retrieves the cost coefficients for the function.
Definition BaseFunction.h:83
std::vector< int > dims
Dimensions of the function.
Definition BaseFunction.h:61