summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2021-02-04 09:28:46 +0100
committerGitHub <noreply@github.com>2021-02-04 09:28:46 +0100
commitcf73d91645b70eb1a78cbe44f6be31d3ed5979b5 (patch)
treec7ba914c8f23d8134fd2a9871dbccd13b2f68456 /eval
parentb434914ac7aafd49adad156dd070af941a813985 (diff)
parentd0569028e1f61417080e7e41d364e30b56338998 (diff)
Merge pull request #16369 from vespa-engine/arnej/use-genspec-in-unit-tests-3
Arnej/use genspec in unit tests 3
Diffstat (limited to 'eval')
-rw-r--r--eval/src/tests/instruction/dense_dot_product_function/dense_dot_product_function_test.cpp32
-rw-r--r--eval/src/tests/instruction/dense_inplace_join_function/dense_inplace_join_function_test.cpp46
-rw-r--r--eval/src/tests/instruction/dense_matmul_function/dense_matmul_function_test.cpp14
-rw-r--r--eval/src/tests/instruction/dense_multi_matmul_function/dense_multi_matmul_function_test.cpp40
-rw-r--r--eval/src/tests/instruction/dense_simple_expand_function/dense_simple_expand_function_test.cpp36
-rw-r--r--eval/src/tests/instruction/dense_single_reduce_function/dense_single_reduce_function_test.cpp22
-rw-r--r--eval/src/tests/instruction/dense_tensor_create_function/dense_tensor_create_function_test.cpp8
-rw-r--r--eval/src/tests/instruction/dense_tensor_peek_function/dense_tensor_peek_function_test.cpp20
-rw-r--r--eval/src/tests/instruction/dense_xw_product_function/dense_xw_product_function_test.cpp23
-rw-r--r--eval/src/tests/instruction/vector_from_doubles_function/vector_from_doubles_function_test.cpp12
10 files changed, 122 insertions, 131 deletions
diff --git a/eval/src/tests/instruction/dense_dot_product_function/dense_dot_product_function_test.cpp b/eval/src/tests/instruction/dense_dot_product_function/dense_dot_product_function_test.cpp
index 82a0baa8741..5121c587d5b 100644
--- a/eval/src/tests/instruction/dense_dot_product_function/dense_dot_product_function_test.cpp
+++ b/eval/src/tests/instruction/dense_dot_product_function/dense_dot_product_function_test.cpp
@@ -3,7 +3,7 @@
#include <vespa/eval/eval/fast_value.h>
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/eval/test/eval_fixture.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/instruction/dense_dot_product_function.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/stash.h>
@@ -18,14 +18,8 @@ using namespace vespalib::eval::test;
const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
-struct MyVecSeq : Sequence {
- double bias;
- double operator[](size_t i) const override { return (i + bias); }
- MyVecSeq(double cellBias) : bias(cellBias) {}
-};
-
TensorSpec makeTensor(size_t numCells, double cellBias) {
- return spec({x(numCells)}, MyVecSeq(cellBias));
+ return GenSpec().idx("x", numCells).seq_bias(cellBias).gen();
}
const double leftBias = 3.0;
@@ -45,7 +39,7 @@ void check_gen_with_result(size_t l, size_t r, double wanted) {
param_repo.add("b", makeTensor(r, rightBias));
vespalib::string expr = "reduce(a*b,sum,x)";
EvalFixture evaluator(prod_factory, expr, param_repo, true);
- EXPECT_EQUAL(spec(wanted), evaluator.result());
+ EXPECT_EQUAL(GenSpec().seq_bias(wanted).gen(), evaluator.result());
EXPECT_EQUAL(evaluator.result(), EvalFixture::ref(expr, param_repo));
auto info = evaluator.find_all<DenseDotProductFunction>();
EXPECT_EQUAL(info.size(), 1u);
@@ -93,16 +87,16 @@ TEST("require that dot product with equal sizes is correct") {
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add("v01_x1", spec({x(1)}, MyVecSeq(2.0)))
- .add("v02_x3", spec({x(3)}, MyVecSeq(4.0)))
- .add("v03_x3", spec({x(3)}, MyVecSeq(5.0)))
- .add("v04_y3", spec({y(3)}, MyVecSeq(10)))
- .add("v05_x5", spec({x(5)}, MyVecSeq(6.0)))
- .add("v06_x5", spec({x(5)}, MyVecSeq(7.0)))
- .add("v07_x5f", spec(float_cells({x(5)}), MyVecSeq(7.0)))
- .add("v08_x5f", spec(float_cells({x(5)}), MyVecSeq(6.0)))
- .add("m01_x3y3", spec({x(3),y(3)}, MyVecSeq(1.0)))
- .add("m02_x3y3", spec({x(3),y(3)}, MyVecSeq(2.0)));
+ .add("v01_x1", GenSpec().idx("x", 1).seq_bias(2.0).gen())
+ .add("v02_x3", GenSpec().idx("x", 3).seq_bias(4.0).gen())
+ .add("v03_x3", GenSpec().idx("x", 3).seq_bias(5.0).gen())
+ .add("v04_y3", GenSpec().idx("y", 3).seq_bias(10).gen())
+ .add("v05_x5", GenSpec().idx("x", 5).seq_bias(6.0).gen())
+ .add("v06_x5", GenSpec().idx("x", 5).seq_bias(7.0).gen())
+ .add("v07_x5f", GenSpec().cells_float().idx("x", 5).seq_bias(7.0).gen())
+ .add("v08_x5f", GenSpec().cells_float().idx("x", 5).seq_bias(6.0).gen())
+ .add("m01_x3y3", GenSpec().idx("x", 3).idx("y", 3).seq_bias(1.0).gen())
+ .add("m02_x3y3", GenSpec().idx("x", 3).idx("y", 3).seq_bias(2.0).gen());
}
EvalFixture::ParamRepo param_repo = make_params();
diff --git a/eval/src/tests/instruction/dense_inplace_join_function/dense_inplace_join_function_test.cpp b/eval/src/tests/instruction/dense_inplace_join_function/dense_inplace_join_function_test.cpp
index 68aa72428b9..327d90f16e8 100644
--- a/eval/src/tests/instruction/dense_inplace_join_function/dense_inplace_join_function_test.cpp
+++ b/eval/src/tests/instruction/dense_inplace_join_function/dense_inplace_join_function_test.cpp
@@ -2,7 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/eval/eval/tensor_function.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/eval/test/eval_fixture.h>
#include <vespa/vespalib/util/stringfmt.h>
@@ -15,35 +15,29 @@ using namespace vespalib::eval::tensor_function;
const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
-double seq_value = 0.0;
-
-struct GlobalSequence : public Sequence {
- GlobalSequence() {}
- double operator[](size_t) const override {
- seq_value += 1.0;
- return seq_value;
- }
- ~GlobalSequence() {}
+GenSpec::seq_t glb = [] (size_t) {
+ static double seq_value = 0.0;
+ seq_value += 1.0;
+ return seq_value;
};
-GlobalSequence seq;
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add("con_x5_A", spec({x(5)}, seq))
- .add("con_x5_B", spec({x(5)}, seq))
- .add("con_x5_C", spec({x(5)}, seq))
- .add("con_x5y3_A", spec({x(5),y(3)}, seq))
- .add("con_x5y3_B", spec({x(5),y(3)}, seq))
- .add_mutable("mut_dbl_A", spec(1.5))
- .add_mutable("mut_dbl_B", spec(2.5))
- .add_mutable("mut_x5_A", spec({x(5)}, seq))
- .add_mutable("mut_x5_B", spec({x(5)}, seq))
- .add_mutable("mut_x5_C", spec({x(5)}, seq))
- .add_mutable("mut_x5f_D", spec(float_cells({x(5)}), seq))
- .add_mutable("mut_x5f_E", spec(float_cells({x(5)}), seq))
- .add_mutable("mut_x5y3_A", spec({x(5),y(3)}, seq))
- .add_mutable("mut_x5y3_B", spec({x(5),y(3)}, seq))
- .add_mutable("mut_x_sparse", spec({x({"a", "b", "c"})}, seq));
+ .add("con_x5_A", GenSpec().idx("x", 5).seq(glb).gen())
+ .add("con_x5_B", GenSpec().idx("x", 5).seq(glb).gen())
+ .add("con_x5_C", GenSpec().idx("x", 5).seq(glb).gen())
+ .add("con_x5y3_A", GenSpec().idx("x", 5).idx("y", 3).seq(glb).gen())
+ .add("con_x5y3_B", GenSpec().idx("x", 5).idx("y", 3).seq(glb).gen())
+ .add_mutable("mut_dbl_A", GenSpec().seq_bias(1.5).gen())
+ .add_mutable("mut_dbl_B", GenSpec().seq_bias(2.5).gen())
+ .add_mutable("mut_x5_A", GenSpec().idx("x", 5).seq(glb).gen())
+ .add_mutable("mut_x5_B", GenSpec().idx("x", 5).seq(glb).gen())
+ .add_mutable("mut_x5_C", GenSpec().idx("x", 5).seq(glb).gen())
+ .add_mutable("mut_x5f_D", GenSpec().cells_float().idx("x", 5).seq(glb).gen())
+ .add_mutable("mut_x5f_E", GenSpec().cells_float().idx("x", 5).seq(glb).gen())
+ .add_mutable("mut_x5y3_A", GenSpec().idx("x", 5).idx("y", 3).seq(glb).gen())
+ .add_mutable("mut_x5y3_B", GenSpec().idx("x", 5).idx("y", 3).seq(glb).gen())
+ .add_mutable("mut_x_sparse", GenSpec().map("x", {"a", "b", "c"}).seq(glb).gen());
}
EvalFixture::ParamRepo param_repo = make_params();
diff --git a/eval/src/tests/instruction/dense_matmul_function/dense_matmul_function_test.cpp b/eval/src/tests/instruction/dense_matmul_function/dense_matmul_function_test.cpp
index 0bafa450ca2..bcc5e6c7b5d 100644
--- a/eval/src/tests/instruction/dense_matmul_function/dense_matmul_function_test.cpp
+++ b/eval/src/tests/instruction/dense_matmul_function/dense_matmul_function_test.cpp
@@ -4,7 +4,7 @@
#include <vespa/eval/eval/operation.h>
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/eval/test/eval_fixture.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/instruction/dense_matmul_function.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/stash.h>
@@ -19,12 +19,12 @@ const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add_matrix("a", 2, "d", 3) // inner/inner
- .add_matrix("a", 2, "b", 5) // inner/outer
- .add_matrix("b", 5, "c", 2) // outer/outer
- .add_matrix("a", 2, "c", 3) // not matching
+ .add_variants("a2d3", GenSpec().idx("a", 2).idx("d", 3)) // inner/inner
+ .add_variants("a2b5", GenSpec().idx("a", 2).idx("b", 5)) // inner/outer
+ .add_variants("b5c2", GenSpec().idx("b", 5).idx("c", 2)) // outer/outer
+ .add_variants("a2c3", GenSpec().idx("a", 2).idx("c", 3)) // not matching
//------------------------------------------
- .add_matrix("b", 5, "d", 3); // fixed param
+ .add_variants("b5d3", GenSpec().idx("b", 5).idx("d", 3)); // fixed param
}
EvalFixture::ParamRepo param_repo = make_params();
@@ -87,7 +87,7 @@ TEST("require that xw product can be debug dumped") {
vespalib::string make_expr(const vespalib::string &a, const vespalib::string &b, const vespalib::string &common,
bool float_a, bool float_b)
{
- return make_string("reduce(%s%s*%s%s,sum,%s)", a.c_str(), float_a ? "f" : "", b.c_str(), float_b ? "f" : "", common.c_str());
+ return make_string("reduce(%s%s*%s%s,sum,%s)", a.c_str(), float_a ? "_f" : "", b.c_str(), float_b ? "_f" : "", common.c_str());
}
void verify_optimized_multi(const vespalib::string &a, const vespalib::string &b, const vespalib::string &common,
diff --git a/eval/src/tests/instruction/dense_multi_matmul_function/dense_multi_matmul_function_test.cpp b/eval/src/tests/instruction/dense_multi_matmul_function/dense_multi_matmul_function_test.cpp
index ac3abe4f05e..9138668b8c4 100644
--- a/eval/src/tests/instruction/dense_multi_matmul_function/dense_multi_matmul_function_test.cpp
+++ b/eval/src/tests/instruction/dense_multi_matmul_function/dense_multi_matmul_function_test.cpp
@@ -4,7 +4,7 @@
#include <vespa/eval/eval/operation.h>
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/eval/test/eval_fixture.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/instruction/dense_multi_matmul_function.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/stash.h>
@@ -17,21 +17,29 @@ using namespace vespalib::eval::tensor_function;
const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
+GenSpec G(std::vector<std::pair<const char *, size_t>> dims) {
+ GenSpec result;
+ for (const auto & dim : dims) {
+ result.idx(dim.first, dim.second);
+ }
+ return result;
+}
+
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add_dense({{"A", 2}, {"B", 1}, {"C", 3}, {"a", 2}, {"d", 3}}) // inner/inner
- .add_dense({{"A", 2}, {"B", 1}, {"C", 3}, {"D", 1}, {"a", 2}, {"c", 1}, {"d", 3}, {"e", 1}}) // inner/inner, extra dims
- .add_dense({{"B", 1}, {"C", 3}, {"a", 2}, {"d", 3}}) // inner/inner, missing A
- .add_dense({{"A", 1}, {"a", 2}, {"d", 3}}) // inner/inner, single mat
- .add_dense({{"A", 2}, {"D", 3}, {"a", 2}, {"b", 1}, {"c", 3}}) // inner/inner, inverted
- .add_dense({{"A", 2}, {"B", 1}, {"C", 3}, {"a", 2}, {"b", 5}}) // inner/outer
- .add_dense({{"A", 2}, {"B", 1}, {"C", 3}, {"b", 5}, {"c", 2}}) // outer/outer
- .add_dense({{"A", 2}, {"B", 1}, {"C", 3}, {"a", 2}, {"c", 3}}) // not matching
+ .add_variants("A2B1C3a2d3", G({{"A",2}, {"B",1}, {"C",3}, {"a",2}, {"d",3}})) // inner/inner
+ .add_variants("A2B1C3D1a2c1d3e1", G({{"A",2}, {"B",1}, {"C",3}, {"D",1}, {"a",2}, {"c",1}, {"d",3}, {"e",1}}))// inner/inner, extra dims
+ .add_variants("B1C3a2d3", G({{"B",1}, {"C",3}, {"a",2}, {"d",3}})) // inner/inner, missing A
+ .add_variants("A1a2d3", G({{"A",1}, {"a",2}, {"d",3}})) // inner/inner, single mat
+ .add_variants("A2D3a2b1c3", G({{"A",2}, {"D",3}, {"a",2}, {"b",1}, {"c",3}})) // inner/inner, inverted
+ .add_variants("A2B1C3a2b5", G({{"A",2}, {"B",1}, {"C",3}, {"a",2}, {"b",5}})) // inner/outer
+ .add_variants("A2B1C3b5c2", G({{"A",2}, {"B",1}, {"C",3}, {"b",5}, {"c",2}})) // outer/outer
+ .add_variants("A2B1C3a2c3", G({{"A",2}, {"B",1}, {"C",3}, {"a",2}, {"c",3}})) // not matching
//----------------------------------------------------------------------------------------
- .add_dense({{"A", 2}, {"B", 1}, {"C", 3}, {"b", 5}, {"d", 3}}) // fixed param
- .add_dense({{"B", 1}, {"C", 3}, {"b", 5}, {"d", 3}}) // fixed param, missing A
- .add_dense({{"A", 1}, {"b", 5}, {"d", 3}}) // fixed param, single mat
- .add_dense({{"B", 5}, {"D", 3}, {"a", 2}, {"b", 1}, {"c", 3}}); // fixed param, inverted
+ .add_variants("A2B1C3b5d3", G({{"A",2}, {"B",1}, {"C",3}, {"b",5}, {"d",3}})) // fixed param
+ .add_variants("B1C3b5d3", G({{"B",1}, {"C",3}, {"b",5}, {"d",3}})) // fixed param, missing A
+ .add_variants("A1b5d3", G({{"A",1}, {"b",5}, {"d",3}})) // fixed param, single mat
+ .add_variants("B5D3a2b1c3", G({{"B",5}, {"D",3}, {"a",2}, {"b",1}, {"c",3}})); // fixed param, inverted
}
EvalFixture::ParamRepo param_repo = make_params();
@@ -90,8 +98,8 @@ TEST("require that expressions similar to multi matmul are not optimized") {
}
TEST("require that multi matmul must have matching cell type") {
- TEST_DO(verify_not_optimized("reduce(A2B1C3a2d3f*A2B1C3b5d3,sum,d)"));
- TEST_DO(verify_not_optimized("reduce(A2B1C3a2d3*A2B1C3b5d3f,sum,d)"));
+ TEST_DO(verify_not_optimized("reduce(A2B1C3a2d3_f*A2B1C3b5d3,sum,d)"));
+ TEST_DO(verify_not_optimized("reduce(A2B1C3a2d3*A2B1C3b5d3_f,sum,d)"));
}
TEST("require that multi matmul must have matching dimension prefix") {
@@ -119,7 +127,7 @@ TEST("require that multi matmul function can be debug dumped") {
vespalib::string make_expr(const vespalib::string &a, const vespalib::string &b, const vespalib::string &common,
bool float_cells)
{
- return make_string("reduce(%s%s*%s%s,sum,%s)", a.c_str(), float_cells ? "f" : "", b.c_str(), float_cells ? "f" : "", common.c_str());
+ return make_string("reduce(%s%s*%s%s,sum,%s)", a.c_str(), float_cells ? "_f" : "", b.c_str(), float_cells ? "_f" : "", common.c_str());
}
void verify_optimized_multi(const vespalib::string &a, const vespalib::string &b, const vespalib::string &common,
diff --git a/eval/src/tests/instruction/dense_simple_expand_function/dense_simple_expand_function_test.cpp b/eval/src/tests/instruction/dense_simple_expand_function/dense_simple_expand_function_test.cpp
index 2c5566e045a..132f88076f6 100644
--- a/eval/src/tests/instruction/dense_simple_expand_function/dense_simple_expand_function_test.cpp
+++ b/eval/src/tests/instruction/dense_simple_expand_function/dense_simple_expand_function_test.cpp
@@ -4,7 +4,7 @@
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/instruction/dense_simple_expand_function.h>
#include <vespa/eval/eval/test/eval_fixture.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/vespalib/gtest/gtest.h>
using namespace vespalib;
@@ -18,17 +18,17 @@ const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add("a", spec(1.5))
- .add("sparse", spec({x({"a"})}, N()))
- .add("mixed", spec({y({"a"}),z(5)}, N()))
- .add_vector("a", 5)
- .add_vector("b", 3)
- .add_cube("A", 1, "a", 5, "c", 1)
- .add_cube("B", 1, "b", 3, "c", 1)
- .add_matrix("a", 5, "c", 3)
- .add_matrix("x", 3, "y", 2)
- .add_cube("a", 1, "b", 1, "c", 1)
- .add_cube("x", 1, "y", 1, "z", 1);
+ .add("a", GenSpec().seq_bias(1.5).gen())
+ .add("sparse", GenSpec().map("x", {"a"}).gen())
+ .add("mixed", GenSpec().map("y", {"a"}).idx("z", 5).gen())
+ .add_variants("a5", GenSpec().idx("a", 5))
+ .add_variants("b3", GenSpec().idx("b", 3))
+ .add_variants("A1a5c1", GenSpec().idx("A", 1).idx("a", 5).idx("c", 1))
+ .add_variants("B1b3c1", GenSpec().idx("B", 1).idx("b", 3).idx("c", 1))
+ .add_variants("a5c3", GenSpec().idx("a", 5).idx("c", 3))
+ .add_variants("x3y2", GenSpec().idx("x", 3).idx("y", 2))
+ .add_variants("a1b1c1", GenSpec().idx("a", 1).idx("b", 1).idx("c", 1))
+ .add_variants("x1y1z1", GenSpec().idx("x", 1).idx("y", 1).idx("z", 1));
}
EvalFixture::ParamRepo param_repo = make_params();
@@ -81,12 +81,12 @@ TEST(ExpandTest, simple_expand_handles_asymmetric_operations_correctly) {
}
TEST(ExpandTest, simple_expand_can_have_various_cell_types) {
- verify_optimized("join(a5,b3f,f(x,y)(x*y))", Inner::RHS);
- verify_optimized("join(a5f,b3,f(x,y)(x*y))", Inner::RHS);
- verify_optimized("join(a5f,b3f,f(x,y)(x*y))", Inner::RHS);
- verify_optimized("join(b3,a5f,f(x,y)(x*y))", Inner::LHS);
- verify_optimized("join(b3f,a5,f(x,y)(x*y))", Inner::LHS);
- verify_optimized("join(b3f,a5f,f(x,y)(x*y))", Inner::LHS);
+ verify_optimized("join(a5,b3_f,f(x,y)(x*y))", Inner::RHS);
+ verify_optimized("join(a5_f,b3,f(x,y)(x*y))", Inner::RHS);
+ verify_optimized("join(a5_f,b3_f,f(x,y)(x*y))", Inner::RHS);
+ verify_optimized("join(b3,a5_f,f(x,y)(x*y))", Inner::LHS);
+ verify_optimized("join(b3_f,a5,f(x,y)(x*y))", Inner::LHS);
+ verify_optimized("join(b3_f,a5_f,f(x,y)(x*y))", Inner::LHS);
}
TEST(ExpandTest, simple_expand_is_never_inplace) {
diff --git a/eval/src/tests/instruction/dense_single_reduce_function/dense_single_reduce_function_test.cpp b/eval/src/tests/instruction/dense_single_reduce_function/dense_single_reduce_function_test.cpp
index c6da0b94de3..2d7b32359bc 100644
--- a/eval/src/tests/instruction/dense_single_reduce_function/dense_single_reduce_function_test.cpp
+++ b/eval/src/tests/instruction/dense_single_reduce_function/dense_single_reduce_function_test.cpp
@@ -4,7 +4,7 @@
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/eval/operation.h>
#include <vespa/eval/instruction/dense_single_reduce_function.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/eval/test/eval_fixture.h>
#include <vespa/vespalib/util/stringfmt.h>
@@ -19,15 +19,15 @@ const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add_dense({{"a", 2}, {"b", 3}, {"c", 4}, {"d", 5}})
- .add_dense({{"a", 9}, {"b", 9}, {"c", 9}, {"d", 9}})
- .add_cube("a", 2, "b", 1, "c", 1)
- .add_cube("a", 1, "b", 2, "c", 1)
- .add_cube("a", 1, "b", 1, "c", 2)
- .add_cube("a", 1, "b", 1, "c", 1)
- .add_vector("a", 10)
- .add("xy_mapped", spec({x({"a", "b"}),y({"x", "y"})}, N()))
- .add("xyz_mixed", spec({x({"a", "b"}),y({"x", "y"}),z(3)}, N()));
+ .add_variants("a2b3c4d5", GenSpec().idx("a", 2).idx("b", 3).idx("c", 4).idx("d", 5))
+ .add_variants("a9b9c9d9", GenSpec().idx("a", 9).idx("b", 9).idx("c", 9).idx("d", 9))
+ .add_variants("a2b1c1", GenSpec().idx("a", 2).idx("b", 1).idx("c", 1))
+ .add_variants("a1b2c1", GenSpec().idx("a", 1).idx("b", 2).idx("c", 1))
+ .add_variants("a1b1c2", GenSpec().idx("a", 1).idx("b", 1).idx("c", 2))
+ .add_variants("a1b1c1", GenSpec().idx("a", 1).idx("b", 1).idx("c", 1))
+ .add_variants("a10", GenSpec().idx("a", 10))
+ .add("xy_mapped", GenSpec().map("x", {"a", "b"}).map("y", {"x", "y"}).gen())
+ .add("xyz_mixed", GenSpec().map("x", {"a", "b"}).map("y", {"x", "y"}).idx("z", 3).gen());
}
EvalFixture::ParamRepo param_repo = make_params();
@@ -124,7 +124,7 @@ TEST("require that non-simple aggregators cannot be decomposed into multiple red
}
vespalib::string make_expr(const vespalib::string &arg, const vespalib::string &dim, bool float_cells, Aggr aggr) {
- return make_string("reduce(%s%s,%s,%s)", arg.c_str(), float_cells ? "f" : "", AggrNames::name_of(aggr)->c_str(), dim.c_str());
+ return make_string("reduce(%s%s,%s,%s)", arg.c_str(), float_cells ? "_f" : "", AggrNames::name_of(aggr)->c_str(), dim.c_str());
}
void verify_optimized_multi(const vespalib::string &arg, const vespalib::string &dim, size_t outer_size, size_t reduce_size, size_t inner_size) {
diff --git a/eval/src/tests/instruction/dense_tensor_create_function/dense_tensor_create_function_test.cpp b/eval/src/tests/instruction/dense_tensor_create_function/dense_tensor_create_function_test.cpp
index 25bbe5b422c..15a677c738d 100644
--- a/eval/src/tests/instruction/dense_tensor_create_function/dense_tensor_create_function_test.cpp
+++ b/eval/src/tests/instruction/dense_tensor_create_function/dense_tensor_create_function_test.cpp
@@ -3,7 +3,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/instruction/dense_tensor_create_function.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/eval/test/eval_fixture.h>
#include <vespa/vespalib/util/stringfmt.h>
@@ -18,9 +18,9 @@ const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add("a", spec(1.0))
- .add("b", spec(2.0))
- .add("c", spec(3.0));
+ .add("a", GenSpec().seq_bias(1.0).gen())
+ .add("b", GenSpec().seq_bias(2.0).gen())
+ .add("c", GenSpec().seq_bias(3.0).gen());
}
EvalFixture::ParamRepo param_repo = make_params();
diff --git a/eval/src/tests/instruction/dense_tensor_peek_function/dense_tensor_peek_function_test.cpp b/eval/src/tests/instruction/dense_tensor_peek_function/dense_tensor_peek_function_test.cpp
index 195b1f0e6ab..3662aa6243a 100644
--- a/eval/src/tests/instruction/dense_tensor_peek_function/dense_tensor_peek_function_test.cpp
+++ b/eval/src/tests/instruction/dense_tensor_peek_function/dense_tensor_peek_function_test.cpp
@@ -3,7 +3,7 @@
#include <vespa/eval/eval/fast_value.h>
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/eval/test/eval_fixture.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/instruction/dense_tensor_peek_function.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/stash.h>
@@ -18,15 +18,15 @@ const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add("a", spec(1.0))
- .add("b", spec(2.0))
- .add("c", spec(3.0))
- .add("x3", spec(x(3), N()))
- .add("x3f", spec(float_cells({x(3)}), N()))
- .add("x3y2", spec({x(3),y(2)}, N()))
- .add("x3y2f", spec(float_cells({x(3),y(2)}), N()))
- .add("xm", spec(x({"1","2","3","-1","-2","-3"}), N()))
- .add("xmy2", spec({x({"1","2","3"}), y(2)}, N()));
+ .add("a", GenSpec().seq_bias(1.0).gen())
+ .add("b", GenSpec().seq_bias(2.0).gen())
+ .add("c", GenSpec().seq_bias(3.0).gen())
+ .add("x3", GenSpec().idx("x", 3).gen())
+ .add("x3f", GenSpec().cells_float().idx("x", 3).gen())
+ .add("x3y2", GenSpec().idx("x", 3).idx("y", 2).gen())
+ .add("x3y2f", GenSpec().cells_float().idx("x", 3).idx("y", 2).gen())
+ .add("xm", GenSpec().map("x", {"1","2","3","-1","-2","-3"}).gen())
+ .add("xmy2", GenSpec().map("x", {"1","2","3"}).idx("y", 2).gen());
}
EvalFixture::ParamRepo param_repo = make_params();
diff --git a/eval/src/tests/instruction/dense_xw_product_function/dense_xw_product_function_test.cpp b/eval/src/tests/instruction/dense_xw_product_function/dense_xw_product_function_test.cpp
index bd69310972c..74ee559b5dc 100644
--- a/eval/src/tests/instruction/dense_xw_product_function/dense_xw_product_function_test.cpp
+++ b/eval/src/tests/instruction/dense_xw_product_function/dense_xw_product_function_test.cpp
@@ -5,7 +5,7 @@
#include <vespa/eval/eval/fast_value.h>
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/eval/test/eval_fixture.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/instruction/dense_xw_product_function.h>
#include <vespa/vespalib/util/stringfmt.h>
@@ -24,26 +24,21 @@ struct First {
operator bool() const { return value; }
};
-struct MyVecSeq : Sequence {
- double operator[](size_t i) const override { return (3.0 + i) * 7.0; }
-};
-
-struct MyMatSeq : Sequence {
- double operator[](size_t i) const override { return (5.0 + i) * 43.0; }
-};
+GenSpec::seq_t my_vec_seq = [] (size_t i) { return (3.0 + i) * 7.0; };
+GenSpec::seq_t my_mat_seq = [] (size_t i) { return (5.0 + i) * 43.0; };
void add_vector(EvalFixture::ParamRepo &repo, const char *d1, size_t s1) {
auto name = make_string("%s%zu", d1, s1);
- auto layout = Layout({{d1, s1}});
- repo.add(name, spec(layout, MyVecSeq()));
- repo.add(name + "f", spec(float_cells(layout), MyVecSeq()));
+ auto layout = GenSpec().idx(d1, s1).seq(my_vec_seq);
+ repo.add(name, layout.gen());
+ repo.add(name + "f", layout.cells_float().gen());
}
void add_matrix(EvalFixture::ParamRepo &repo, const char *d1, size_t s1, const char *d2, size_t s2) {
auto name = make_string("%s%zu%s%zu", d1, s1, d2, s2);
- auto layout = Layout({{d1, s1}, {d2, s2}});
- repo.add(name, spec(layout, MyMatSeq()));
- repo.add(name + "f", spec(float_cells(layout), MyMatSeq()));
+ auto layout = GenSpec().idx(d1, s1).idx(d2, s2).seq(my_mat_seq);
+ repo.add(name, layout.gen());
+ repo.add(name + "f", layout.cells_float().gen());
}
EvalFixture::ParamRepo make_params() {
diff --git a/eval/src/tests/instruction/vector_from_doubles_function/vector_from_doubles_function_test.cpp b/eval/src/tests/instruction/vector_from_doubles_function/vector_from_doubles_function_test.cpp
index 4f4829c3ae1..2371c1e4006 100644
--- a/eval/src/tests/instruction/vector_from_doubles_function/vector_from_doubles_function_test.cpp
+++ b/eval/src/tests/instruction/vector_from_doubles_function/vector_from_doubles_function_test.cpp
@@ -3,7 +3,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/eval/eval/tensor_function.h>
#include <vespa/eval/instruction/vector_from_doubles_function.h>
-#include <vespa/eval/eval/test/tensor_model.hpp>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <vespa/eval/eval/test/eval_fixture.h>
#include <vespa/vespalib/util/stringfmt.h>
@@ -18,11 +18,11 @@ const ValueBuilderFactory &prod_factory = FastValueBuilderFactory::get();
EvalFixture::ParamRepo make_params() {
return EvalFixture::ParamRepo()
- .add("a", spec(1.0))
- .add("b", spec(2.0))
- .add("c", spec(3.0))
- .add("d", spec(4.0))
- .add("x5", spec({x(5)}, N()));
+ .add("a", GenSpec().seq_bias(1.0).gen())
+ .add("b", GenSpec().seq_bias(2.0).gen())
+ .add("c", GenSpec().seq_bias(3.0).gen())
+ .add("d", GenSpec().seq_bias(4.0).gen())
+ .add("x5", GenSpec().idx("x", 5).gen());
}
EvalFixture::ParamRepo param_repo = make_params();