From de041f07452bac80405d043bdad7b0d05b640bd2 Mon Sep 17 00:00:00 2001 From: HÃ¥vard Pettersen Date: Thu, 2 Apr 2020 11:12:28 +0000 Subject: remove parameter count from interpreted functions --- .../tests/eval/interpreted_function/interpreted_function_test.cpp | 1 - eval/src/vespa/eval/eval/basic_nodes.cpp | 2 +- eval/src/vespa/eval/eval/interpreted_function.cpp | 4 +--- eval/src/vespa/eval/eval/interpreted_function.h | 6 ++---- eval/src/vespa/eval/eval/make_tensor_function.cpp | 6 +++--- 5 files changed, 7 insertions(+), 12 deletions(-) (limited to 'eval') 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(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 _program; Stash _stash; - size_t _num_params; const TensorEngine &_tensor_engine; public: typedef std::unique_ptr 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 ¶ms) const; double estimate_cost_us(const std::vector ¶ms, 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(tensor_engine.from_spec(spec))); } else { stack.push_back(tensor_function::lambda(node.type(), node.bindings(), std::move(my_fun), stash)); -- cgit v1.2.3