aboutsummaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2018-01-15 15:05:10 +0000
committerHåvard Pettersen <havardpe@oath.com>2018-01-16 09:49:34 +0000
commit772fc30ac5acc00dd8122969ceb0dff0770e23f5 (patch)
treef100451e955b63ca2f95f1a12d2fc88db69dc0dc /eval
parent22b1a85a65c88559446a6919bb6828ed2665e315 (diff)
move LazyParams to separate file
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/CMakeLists.txt1
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.cpp4
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.h10
-rw-r--r--eval/src/vespa/eval/eval/lazy_params.cpp11
-rw-r--r--eval/src/vespa/eval/eval/lazy_params.h27
-rw-r--r--eval/src/vespa/eval/eval/llvm/compiled_function.h3
6 files changed, 44 insertions, 12 deletions
diff --git a/eval/src/vespa/eval/eval/CMakeLists.txt b/eval/src/vespa/eval/eval/CMakeLists.txt
index dd5c651202b..468b73a509b 100644
--- a/eval/src/vespa/eval/eval/CMakeLists.txt
+++ b/eval/src/vespa/eval/eval/CMakeLists.txt
@@ -9,6 +9,7 @@ vespa_add_library(eval_eval OBJECT
gbdt.cpp
interpreted_function.cpp
key_gen.cpp
+ lazy_params.cpp
node_types.cpp
operation.cpp
operator_nodes.cpp
diff --git a/eval/src/vespa/eval/eval/interpreted_function.cpp b/eval/src/vespa/eval/eval/interpreted_function.cpp
index ada942767fa..81309956e58 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.cpp
+++ b/eval/src/vespa/eval/eval/interpreted_function.cpp
@@ -469,10 +469,6 @@ const Function *get_lambda(const nodes::Node &node) {
} // namespace vespalib::<unnamed>
-InterpretedFunction::LazyParams::~LazyParams()
-{
-}
-
InterpretedFunction::SimpleParams::SimpleParams(const std::vector<double> &params_in)
: params(params_in)
{}
diff --git a/eval/src/vespa/eval/eval/interpreted_function.h b/eval/src/vespa/eval/eval/interpreted_function.h
index 8d20d8d5222..0741e7e4191 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.h
+++ b/eval/src/vespa/eval/eval/interpreted_function.h
@@ -5,6 +5,7 @@
#include "function.h"
#include "simple_tensor_engine.h"
#include "node_types.h"
+#include "lazy_params.h"
#include <vespa/vespalib/util/stash.h>
namespace vespalib {
@@ -26,13 +27,8 @@ class TensorEngine;
class InterpretedFunction
{
public:
- /**
- * Interface used to lazy-resolve parameters when needed.
- **/
- struct LazyParams {
- virtual const Value &resolve(size_t idx, Stash &stash) const = 0;
- virtual ~LazyParams();
- };
+ using LazyParams = ::vespalib::eval::LazyParams;
+
/**
* Simple wrapper for number-only parameters that are known up
* front. Intended for convenience (testing), not performance.
diff --git a/eval/src/vespa/eval/eval/lazy_params.cpp b/eval/src/vespa/eval/eval/lazy_params.cpp
new file mode 100644
index 00000000000..ba8f8a2a002
--- /dev/null
+++ b/eval/src/vespa/eval/eval/lazy_params.cpp
@@ -0,0 +1,11 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "lazy_params.h"
+
+namespace vespalib::eval {
+
+LazyParams::~LazyParams()
+{
+}
+
+} // namespace vespalib::eval
diff --git a/eval/src/vespa/eval/eval/lazy_params.h b/eval/src/vespa/eval/eval/lazy_params.h
new file mode 100644
index 00000000000..40436fc2c92
--- /dev/null
+++ b/eval/src/vespa/eval/eval/lazy_params.h
@@ -0,0 +1,27 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <stddef.h>
+
+namespace vespalib {
+
+class Stash;
+
+namespace eval {
+
+class Value;
+
+/**
+ * Interface used to lazy-resolve parameters.
+ **/
+struct LazyParams {
+ // used by compiled code to resolve lazy double-only parameters
+ using resolve_function = double (*)(void *ctx, size_t idx);
+
+ virtual const Value &resolve(size_t idx, Stash &stash) const = 0;
+ virtual ~LazyParams();
+};
+
+} // namespace vespalib::eval
+} // namespace vespalib
diff --git a/eval/src/vespa/eval/eval/llvm/compiled_function.h b/eval/src/vespa/eval/eval/llvm/compiled_function.h
index 7a0f4a709a4..40737e3ff92 100644
--- a/eval/src/vespa/eval/eval/llvm/compiled_function.h
+++ b/eval/src/vespa/eval/eval/llvm/compiled_function.h
@@ -3,6 +3,7 @@
#pragma once
#include <vespa/eval/eval/function.h>
+#include <vespa/eval/eval/lazy_params.h>
#include <vespa/eval/eval/gbdt.h>
#include "llvm_wrapper.h"
@@ -26,7 +27,7 @@ public:
using array_function = double (*)(const double *);
- using resolve_function = double (*)(void *ctx, size_t idx);
+ using resolve_function = LazyParams::resolve_function;
using lazy_function = double (*)(resolve_function, void *ctx);
private: