aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/tests
diff options
context:
space:
mode:
authorHÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com>2021-08-25 10:29:07 +0200
committerGitHub <noreply@github.com>2021-08-25 10:29:07 +0200
commitcdf4bbf395ee8775ce029e01910d26e2a4aee8e2 (patch)
tree073aff3521732ac24b30a2eb935632216dac79cc /eval/src/tests
parent25a715b5479f1a8d001dbc2e6d4993652f82ba67 (diff)
parentfbf0652e9e85e79eefb738149d48b94ce9f3909f (diff)
Merge pull request #18844 from vespa-engine/havardpe/tensor-as-expression
enable making an expression from a tensor spec.
Diffstat (limited to 'eval/src/tests')
-rw-r--r--eval/src/tests/eval/tensor_spec/tensor_spec_test.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/eval/src/tests/eval/tensor_spec/tensor_spec_test.cpp b/eval/src/tests/eval/tensor_spec/tensor_spec_test.cpp
index aa62e52f6f4..7c48606d6dd 100644
--- a/eval/src/tests/eval/tensor_spec/tensor_spec_test.cpp
+++ b/eval/src/tests/eval/tensor_spec/tensor_spec_test.cpp
@@ -19,6 +19,17 @@ TEST("require that a tensor spec can be converted to and from slime") {
EXPECT_EQUAL(TensorSpec::from_slime(slime.get()), spec);
}
+TEST("require that a tensor spec can be converted to and from an expression") {
+ TensorSpec spec("tensor<float>(x[2],y{})");
+ spec.add({{"x", 0}, {"y", "xxx"}}, 1.0)
+ .add({{"x", 0}, {"y", "yyy"}}, 2.0)
+ .add({{"x", 1}, {"y", "xxx"}}, 3.0)
+ .add({{"x", 1}, {"y", "yyy"}}, 4.0);
+ vespalib::string expr = spec.to_expr();
+ fprintf(stderr, "expr: \n%s\n", expr.c_str());
+ EXPECT_EQUAL(TensorSpec::from_expr(expr), spec);
+}
+
TEST("require that tensor specs can be diffed") {
TensorSpec expect("tensor(x[2],y{})");
expect.add({{"x", 0}, {"y", "xxx"}}, 1.5)