summaryrefslogtreecommitdiffstats
path: root/eval/src/tests/eval/tensor_function/tensor_function_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'eval/src/tests/eval/tensor_function/tensor_function_test.cpp')
-rw-r--r--eval/src/tests/eval/tensor_function/tensor_function_test.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/eval/src/tests/eval/tensor_function/tensor_function_test.cpp b/eval/src/tests/eval/tensor_function/tensor_function_test.cpp
index b5f9e22a5cb..4396a6773ea 100644
--- a/eval/src/tests/eval/tensor_function/tensor_function_test.cpp
+++ b/eval/src/tests/eval/tensor_function/tensor_function_test.cpp
@@ -16,14 +16,14 @@ using namespace vespalib::eval::tensor_function;
const auto &simple_factory = SimpleValueBuilderFactory::get();
struct EvalCtx {
- EngineOrFactory engine;
+ const ValueBuilderFactory &factory;
Stash stash;
std::vector<Value::UP> tensors;
std::vector<Value::CREF> params;
InterpretedFunction::UP ifun;
std::unique_ptr<InterpretedFunction::Context> ictx;
- EvalCtx(EngineOrFactory engine_in)
- : engine(engine_in), stash(), tensors(), params(), ifun(), ictx() {}
+ EvalCtx(const ValueBuilderFactory &factory_in)
+ : factory(factory_in), stash(), tensors(), params(), ifun(), ictx() {}
~EvalCtx() {}
size_t add_tensor(Value::UP tensor) {
size_t id = params.size();
@@ -36,18 +36,18 @@ struct EvalCtx {
tensors[idx] = std::move(tensor);
}
const Value &eval(const TensorFunction &fun) {
- ifun = std::make_unique<InterpretedFunction>(engine, fun);
+ ifun = std::make_unique<InterpretedFunction>(factory, fun);
ictx = std::make_unique<InterpretedFunction::Context>(*ifun);
return ifun->eval(*ictx, SimpleObjectParams(params));
}
Value::UP make_double(double value) {
- return engine.from_spec(TensorSpec("double").add({}, value));
+ return value_from_spec(TensorSpec("double").add({}, value), factory);
}
Value::UP make_true() {
- return engine.from_spec(TensorSpec("double").add({}, 1.0));
+ return value_from_spec(TensorSpec("double").add({}, 1.0), factory);
}
Value::UP make_false() {
- return engine.from_spec(TensorSpec("double").add({}, 0.0));
+ return value_from_spec(TensorSpec("double").add({}, 0.0), factory);
}
Value::UP make_vector(std::initializer_list<double> cells, vespalib::string dim = "x", bool mapped = false) {
vespalib::string type_spec = mapped
@@ -61,119 +61,119 @@ struct EvalCtx {
: TensorSpec::Label(idx++);
spec.add({{dim, label}}, cell_value);
}
- return engine.from_spec(spec);
+ return value_from_spec(spec, factory);
}
Value::UP make_mixed_tensor(double a, double b, double c, double d) {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{},y[2])")
.add({{"x", "foo"}, {"y", 0}}, a)
.add({{"x", "foo"}, {"y", 1}}, b)
.add({{"x", "bar"}, {"y", 0}}, c)
- .add({{"x", "bar"}, {"y", 1}}, d));
+ .add({{"x", "bar"}, {"y", 1}}, d), factory);
}
Value::UP make_tensor_matrix_first_half() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x[2])")
.add({{"x", 0}}, 1.0)
- .add({{"x", 1}}, 3.0));
+ .add({{"x", 1}}, 3.0), factory);
}
Value::UP make_tensor_matrix_second_half() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x[2])")
.add({{"x", 0}}, 2.0)
- .add({{"x", 1}}, 4.0));
+ .add({{"x", 1}}, 4.0), factory);
}
Value::UP make_tensor_matrix() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x[2],y[2])")
.add({{"x", 0}, {"y", 0}}, 1.0)
.add({{"x", 0}, {"y", 1}}, 2.0)
.add({{"x", 1}, {"y", 0}}, 3.0)
- .add({{"x", 1}, {"y", 1}}, 4.0));
+ .add({{"x", 1}, {"y", 1}}, 4.0), factory);
}
Value::UP make_tensor_matrix_renamed() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(y[2],z[2])")
.add({{"z", 0}, {"y", 0}}, 1.0)
.add({{"z", 0}, {"y", 1}}, 2.0)
.add({{"z", 1}, {"y", 0}}, 3.0)
- .add({{"z", 1}, {"y", 1}}, 4.0));
+ .add({{"z", 1}, {"y", 1}}, 4.0), factory);
}
Value::UP make_tensor_reduce_input() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x[3],y[2])")
.add({{"x",0},{"y",0}}, 1)
.add({{"x",1},{"y",0}}, 2)
.add({{"x",2},{"y",0}}, 3)
.add({{"x",0},{"y",1}}, 4)
.add({{"x",1},{"y",1}}, 5)
- .add({{"x",2},{"y",1}}, 6));
+ .add({{"x",2},{"y",1}}, 6), factory);
}
Value::UP make_tensor_reduce_y_output() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x[3])")
.add({{"x",0}}, 5)
.add({{"x",1}}, 7)
- .add({{"x",2}}, 9));
+ .add({{"x",2}}, 9), factory);
}
Value::UP make_tensor_map_input() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{},y{})")
.add({{"x","1"},{"y","1"}}, 1)
.add({{"x","2"},{"y","1"}}, -3)
- .add({{"x","1"},{"y","2"}}, 5));
+ .add({{"x","1"},{"y","2"}}, 5), factory);
}
Value::UP make_tensor_map_output() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{},y{})")
.add({{"x","1"},{"y","1"}}, -1)
.add({{"x","2"},{"y","1"}}, 3)
- .add({{"x","1"},{"y","2"}}, -5));
+ .add({{"x","1"},{"y","2"}}, -5), factory);
}
Value::UP make_tensor_join_lhs() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{},y{})")
.add({{"x","1"},{"y","1"}}, 1)
.add({{"x","2"},{"y","1"}}, 3)
- .add({{"x","1"},{"y","2"}}, 5));
+ .add({{"x","1"},{"y","2"}}, 5), factory);
}
Value::UP make_tensor_join_rhs() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(y{},z{})")
.add({{"y","1"},{"z","1"}}, 7)
.add({{"y","2"},{"z","1"}}, 11)
- .add({{"y","1"},{"z","2"}}, 13));
+ .add({{"y","1"},{"z","2"}}, 13), factory);
}
Value::UP make_tensor_join_output() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{},y{},z{})")
.add({{"x","1"},{"y","1"},{"z","1"}}, 7)
.add({{"x","1"},{"y","1"},{"z","2"}}, 13)
.add({{"x","2"},{"y","1"},{"z","1"}}, 21)
.add({{"x","2"},{"y","1"},{"z","2"}}, 39)
- .add({{"x","1"},{"y","2"},{"z","1"}}, 55));
+ .add({{"x","1"},{"y","2"},{"z","1"}}, 55), factory);
}
Value::UP make_tensor_merge_lhs() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{})")
.add({{"x","1"}}, 1)
.add({{"x","2"}}, 3)
- .add({{"x","3"}}, 5));
+ .add({{"x","3"}}, 5), factory);
}
Value::UP make_tensor_merge_rhs() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{})")
.add({{"x","2"}}, 7)
.add({{"x","3"}}, 9)
- .add({{"x","4"}}, 11));
+ .add({{"x","4"}}, 11), factory);
}
Value::UP make_tensor_merge_output() {
- return engine.from_spec(
+ return value_from_spec(
TensorSpec("tensor(x{})")
.add({{"x","1"}}, 1)
.add({{"x","2"}}, 10)
.add({{"x","3"}}, 14)
- .add({{"x","4"}}, 11));
+ .add({{"x","4"}}, 11), factory);
}
};