summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2020-04-02 11:12:28 +0000
committerHåvard Pettersen <havardpe@oath.com>2020-04-03 09:38:00 +0000
commitde041f07452bac80405d043bdad7b0d05b640bd2 (patch)
treef404b89a1a0f597e0bc0e259cf4b89cfd841d825 /eval
parent5bd3905bb0b4a69243a6c8d3960ed47b454d44f0 (diff)
remove parameter count from interpreted functions
Diffstat (limited to 'eval')
-rw-r--r--eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp1
-rw-r--r--eval/src/vespa/eval/eval/basic_nodes.cpp2
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.cpp4
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.h6
-rw-r--r--eval/src/vespa/eval/eval/make_tensor_function.cpp6
5 files changed, 7 insertions, 12 deletions
diff --git a/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp b/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp
index d946d244d17..60700817266 100644
--- a/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp
+++ b/eval/src/tests/eval/interpreted_function/interpreted_function_test.cpp
@@ -83,7 +83,6 @@ struct MyEvalTest : test::EvalSpec::EvalTest {
? NodeTypes(function, std::vector<ValueType>(params.params.size(), ValueType::double_type()))
: NodeTypes();
InterpretedFunction ifun(engine, function, node_types);
- ASSERT_EQUAL(ifun.num_params(), params.params.size());
InterpretedFunction::Context ictx(ifun);
const Value &result_value = ifun.eval(ictx, params);
report_result(result_value.is_double(), result_value.as_double(), expected_result, description);
diff --git a/eval/src/vespa/eval/eval/basic_nodes.cpp b/eval/src/vespa/eval/eval/basic_nodes.cpp
index 9d2b3a619fb..bc7202bebc1 100644
--- a/eval/src/vespa/eval/eval/basic_nodes.cpp
+++ b/eval/src/vespa/eval/eval/basic_nodes.cpp
@@ -25,7 +25,7 @@ struct Frame {
double
Node::get_const_value() const {
assert(is_const());
- InterpretedFunction function(SimpleTensorEngine::ref(), *this, 0, NodeTypes());
+ InterpretedFunction function(SimpleTensorEngine::ref(), *this, NodeTypes());
NoParams no_params;
InterpretedFunction::Context ctx(function);
return function.eval(ctx, no_params).as_double();
diff --git a/eval/src/vespa/eval/eval/interpreted_function.cpp b/eval/src/vespa/eval/eval/interpreted_function.cpp
index ec28604fd87..f69893ad014 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.cpp
+++ b/eval/src/vespa/eval/eval/interpreted_function.cpp
@@ -61,16 +61,14 @@ InterpretedFunction::Context::Context(const InterpretedFunction &ifun)
InterpretedFunction::InterpretedFunction(const TensorEngine &engine, const TensorFunction &function)
: _program(),
_stash(),
- _num_params(0),
_tensor_engine(engine)
{
_program = compile_tensor_function(function, _stash);
}
-InterpretedFunction::InterpretedFunction(const TensorEngine &engine, const nodes::Node &root, size_t num_params_in, const NodeTypes &types)
+InterpretedFunction::InterpretedFunction(const TensorEngine &engine, const nodes::Node &root, const NodeTypes &types)
: _program(),
_stash(),
- _num_params(num_params_in),
_tensor_engine(engine)
{
const TensorFunction &plain_fun = make_tensor_function(engine, root, types, _stash);
diff --git a/eval/src/vespa/eval/eval/interpreted_function.h b/eval/src/vespa/eval/eval/interpreted_function.h
index e638ccffcea..fb67fcb0b74 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.h
+++ b/eval/src/vespa/eval/eval/interpreted_function.h
@@ -87,20 +87,18 @@ public:
private:
std::vector<Instruction> _program;
Stash _stash;
- size_t _num_params;
const TensorEngine &_tensor_engine;
public:
typedef std::unique_ptr<InterpretedFunction> UP;
// for testing; use with care; the tensor function must be kept alive
InterpretedFunction(const TensorEngine &engine, const TensorFunction &function);
- InterpretedFunction(const TensorEngine &engine, const nodes::Node &root, size_t num_params_in, const NodeTypes &types);
+ InterpretedFunction(const TensorEngine &engine, const nodes::Node &root, const NodeTypes &types);
InterpretedFunction(const TensorEngine &engine, const Function &function, const NodeTypes &types)
- : InterpretedFunction(engine, function.root(), function.num_params(), types) {}
+ : InterpretedFunction(engine, function.root(), types) {}
InterpretedFunction(InterpretedFunction &&rhs) = default;
~InterpretedFunction();
size_t program_size() const { return _program.size(); }
- size_t num_params() const { return _num_params; }
const Value &eval(Context &ctx, const LazyParams &params) const;
double estimate_cost_us(const std::vector<double> &params, double budget = 5.0) const;
static Function::Issues detect_issues(const Function &function);
diff --git a/eval/src/vespa/eval/eval/make_tensor_function.cpp b/eval/src/vespa/eval/eval/make_tensor_function.cpp
index bbf6cadbac2..b264c3c2fe7 100644
--- a/eval/src/vespa/eval/eval/make_tensor_function.cpp
+++ b/eval/src/vespa/eval/eval/make_tensor_function.cpp
@@ -122,10 +122,10 @@ struct TensorFunctionBuilder : public NodeVisitor, public NodeTraverser {
}
void make_lambda(const TensorLambda &node) {
- InterpretedFunction my_fun(tensor_engine, node.lambda().root(), node.type().dimensions().size(), types);
+ InterpretedFunction my_fun(tensor_engine, node.lambda().root(), types);
if (node.bindings().empty()) {
- NoParams no_params;
- TensorSpec spec = tensor_function::Lambda::create_spec_impl(node.type(), no_params, node.bindings(), my_fun);
+ NoParams no_bound_params;
+ TensorSpec spec = tensor_function::Lambda::create_spec_impl(node.type(), no_bound_params, node.bindings(), my_fun);
make_const(node, *stash.create<Value::UP>(tensor_engine.from_spec(spec)));
} else {
stack.push_back(tensor_function::lambda(node.type(), node.bindings(), std::move(my_fun), stash));