summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval/src/tests/tensor/instruction_benchmark/instruction_benchmark.cpp229
1 files changed, 93 insertions, 136 deletions
diff --git a/eval/src/tests/tensor/instruction_benchmark/instruction_benchmark.cpp b/eval/src/tests/tensor/instruction_benchmark/instruction_benchmark.cpp
index 3345d7dc8ee..000794aca7d 100644
--- a/eval/src/tests/tensor/instruction_benchmark/instruction_benchmark.cpp
+++ b/eval/src/tests/tensor/instruction_benchmark/instruction_benchmark.cpp
@@ -43,6 +43,7 @@
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/data/smart_buffer.h>
+#include <vespa/eval/eval/test/gen_spec.h>
#include <optional>
#include <algorithm>
@@ -60,51 +61,7 @@ template <typename T> using CREF = std::reference_wrapper<const T>;
//-----------------------------------------------------------------------------
-struct D {
- vespalib::string name;
- bool mapped;
- size_t size;
- size_t stride;
- static D map(const vespalib::string &name_in, size_t size_in, size_t stride_in) { return D{name_in, true, size_in, stride_in}; }
- static D idx(const vespalib::string &name_in, size_t size_in) { return D{name_in, false, size_in, 1}; }
- operator ValueType::Dimension() const {
- if (mapped) {
- return ValueType::Dimension(name);
- } else {
- return ValueType::Dimension(name, size);
- }
- }
- TensorSpec::Label operator()(size_t idx) const {
- if (mapped) {
- // need plain number as string for dynamic sparse peek
- return TensorSpec::Label(fmt("%zu", idx));
- } else {
- return TensorSpec::Label(idx);
- }
- }
-};
-
-void add_cells(TensorSpec &spec, double &seq, TensorSpec::Address addr) {
- spec.add(addr, seq);
- seq += 1.0;
-}
-
-template <typename ...Ds> void add_cells(TensorSpec &spec, double &seq, TensorSpec::Address addr, const D &d, const Ds &...ds) {
- for (size_t i = 0, idx = 0; i < d.size; ++i, idx += d.stride) {
- addr.insert_or_assign(d.name, d(idx));
- add_cells(spec, seq, addr, ds...);
- }
-}
-
-template <typename ...Ds> TensorSpec make_spec(double seq, const Ds &...ds) {
- TensorSpec spec(ValueType::tensor_type({ds...}, CellType::FLOAT).to_spec());
- add_cells(spec, seq, TensorSpec::Address(), ds...);
- return spec;
-}
-
-TensorSpec make_vector(const D &d1, double seq) { return make_spec(seq, d1); }
-TensorSpec make_matrix(const D &d1, const D &d2, double seq) { return make_spec(seq, d1, d2); }
-TensorSpec make_cube(const D &d1, const D &d2, const D &d3, double seq) { return make_spec(seq, d1, d2, d3); }
+test::GenSpec GS(double bias) { return test::GenSpec().cells_float().seq_bias(bias); }
//-----------------------------------------------------------------------------
@@ -609,7 +566,7 @@ void benchmark_tensor_create(const vespalib::string &desc, const TensorSpec &pro
ASSERT_FALSE(proto_type.is_error());
std::vector<CREF<TensorSpec>> stack_spec;
for (const auto &cell: proto.cells()) {
- stack_spec.emplace_back(stash.create<TensorSpec>(make_spec(cell.second)));
+ stack_spec.emplace_back(stash.create<TensorSpec>(GS(cell.second).gen()));
}
std::vector<EvalOp::UP> list;
for (const Impl &impl: impl_list) {
@@ -645,7 +602,7 @@ void benchmark_tensor_peek(const vespalib::string &desc, const TensorSpec &lhs,
stack_spec.emplace_back(lhs);
if (peek_spec.is_dynamic) {
for (const auto &entry: peek_spec.spec) {
- stack_spec.emplace_back(stash.create<TensorSpec>(make_spec(double(entry.second))));
+ stack_spec.emplace_back(stash.create<TensorSpec>(GS(double(entry.second)).gen()));
}
}
std::vector<EvalOp::UP> list;
@@ -660,10 +617,10 @@ void benchmark_tensor_peek(const vespalib::string &desc, const TensorSpec &lhs,
//-----------------------------------------------------------------------------
TEST(MakeInputTest, print_some_test_input) {
- auto number = make_spec(5.0);
- auto sparse = make_vector(D::map("x", 5, 3), 1.0);
- auto dense = make_vector(D::idx("x", 5), 10.0);
- auto mixed = make_cube(D::map("x", 3, 7), D::idx("y", 2), D::idx("z", 2), 100.0);
+ auto number = GS(5.0).gen();
+ auto sparse = GS(1.0).map("x", 5, 3).gen();
+ auto dense = GS(10.0).idx("x", 5).gen();
+ auto mixed = GS(100.0).map("x", 3, 7).idx("y", 2).idx("z", 2).gen();
fprintf(stderr, "--------------------------------------------------------\n");
fprintf(stderr, "simple number: %s\n", number.to_string().c_str());
fprintf(stderr, "sparse vector: %s\n", sparse.to_string().c_str());
@@ -728,197 +685,197 @@ void benchmark_encode_decode(const vespalib::string &desc, const TensorSpec &pro
// relevant for the overall performance of the tensor implementation.
TEST(EncodeDecodeBench, encode_decode_dense) {
- auto proto = make_matrix(D::idx("a", 64), D::idx("b", 64), 1.0);
+ auto proto = GS(1.0).idx("a", 64).idx("b", 64).gen();
benchmark_encode_decode("dense tensor", proto);
}
TEST(EncodeDecodeBench, encode_decode_sparse) {
- auto proto = make_matrix(D::map("a", 64, 1), D::map("b", 64, 1), 1.0);
+ auto proto = GS(1.0).map("a", 64, 1).map("b", 64, 1).gen();
benchmark_encode_decode("sparse tensor", proto);
}
TEST(EncodeDecodeBench, encode_decode_mixed) {
- auto proto = make_matrix(D::map("a", 64, 1), D::idx("b", 64), 1.0);
+ auto proto = GS(1.0).map("a", 64, 1).idx("b", 64).gen();
benchmark_encode_decode("mixed tensor", proto);
}
//-----------------------------------------------------------------------------
TEST(DenseConcat, small_vectors) {
- auto lhs = make_vector(D::idx("x", 10), 1.0);
- auto rhs = make_vector(D::idx("x", 10), 2.0);
+ auto lhs = GS(1.0).idx("x", 10).gen();
+ auto rhs = GS(2.0).idx("x", 10).gen();
benchmark_concat("small dense vector append concat", lhs, rhs, "x");
}
TEST(DenseConcat, cross_vectors) {
- auto lhs = make_vector(D::idx("x", 10), 1.0);
- auto rhs = make_vector(D::idx("x", 10), 2.0);
+ auto lhs = GS(1.0).idx("x", 10).gen();
+ auto rhs = GS(2.0).idx("x", 10).gen();
benchmark_concat("small dense vector cross concat", lhs, rhs, "y");
}
TEST(DenseConcat, cube_and_vector) {
- auto lhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::idx("c", 16), 1.0);
- auto rhs = make_vector(D::idx("a", 16), 42.0);
+ auto lhs = GS(1.0).idx("a", 16).idx("b", 16).idx("c", 16).gen();
+ auto rhs = GS(42.0).idx("a", 16).gen();
benchmark_concat("cube vs vector concat", lhs, rhs, "a");
}
TEST(SparseConcat, small_vectors) {
- auto lhs = make_vector(D::map("x", 10, 1), 1.0);
- auto rhs = make_vector(D::map("x", 10, 2), 2.0);
+ auto lhs = GS(1.0).map("x", 10, 1).gen();
+ auto rhs = GS(2.0).map("x", 10, 2).gen();
benchmark_concat("small sparse concat", lhs, rhs, "y");
}
TEST(MixedConcat, mixed_vs_dense) {
- auto lhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::map("c", 16, 1), 1.0);
- auto rhs = make_matrix(D::idx("a", 16), D::idx("b", 16), 2.0);
+ auto lhs = GS(1.0).idx("a", 16).idx("b", 16).map("c", 16, 1).gen();
+ auto rhs = GS(2.0).idx("a", 16).idx("b", 16).gen();
benchmark_concat("mixed dense concat a", lhs, rhs, "a");
}
TEST(MixedConcat, large_mixed_a) {
- auto lhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::map("c", 16, 1), 1.0);
- auto rhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::map("c", 16, 2), 2.0);
+ auto lhs = GS(1.0).idx("a", 16).idx("b", 16).map("c", 16, 1).gen();
+ auto rhs = GS(2.0).idx("a", 16).idx("b", 16).map("c", 16, 2).gen();
benchmark_concat("mixed append concat a", lhs, rhs, "a");
}
TEST(MixedConcat, large_mixed_b) {
- auto lhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::map("c", 16, 1), 1.0);
- auto rhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::map("c", 16, 2), 2.0);
+ auto lhs = GS(1.0).idx("a", 16).idx("b", 16).map("c", 16, 1).gen();
+ auto rhs = GS(2.0).idx("a", 16).idx("b", 16).map("c", 16, 2).gen();
benchmark_concat("mixed append concat b", lhs, rhs, "b");
}
//-----------------------------------------------------------------------------
TEST(NumberJoin, plain_op2) {
- auto lhs = make_spec(2.0);
- auto rhs = make_spec(3.0);
+ auto lhs = GS(2.0).gen();
+ auto rhs = GS(3.0).gen();
benchmark_join("simple numbers multiply", lhs, rhs, operation::Mul::f);
}
//-----------------------------------------------------------------------------
TEST(DenseJoin, small_vectors) {
- auto lhs = make_vector(D::idx("x", 10), 1.0);
- auto rhs = make_vector(D::idx("x", 10), 2.0);
+ auto lhs = GS(1.0).idx("x", 10).gen();
+ auto rhs = GS(2.0).idx("x", 10).gen();
benchmark_join("small dense vector multiply", lhs, rhs, operation::Mul::f);
}
TEST(DenseJoin, full_overlap) {
- auto lhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::idx("c", 16), 1.0);
- auto rhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::idx("c", 16), 2.0);
+ auto lhs = GS(1.0).idx("a", 16).idx("b", 16).idx("c", 16).gen();
+ auto rhs = GS(2.0).idx("a", 16).idx("b", 16).idx("c", 16).gen();
benchmark_join("dense full overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(DenseJoin, partial_overlap) {
- auto lhs = make_cube(D::idx("a", 8), D::idx("c", 8), D::idx("d", 8), 1.0);
- auto rhs = make_cube(D::idx("b", 8), D::idx("c", 8), D::idx("d", 8), 2.0);
+ auto lhs = GS(1.0).idx("a", 8).idx("c", 8).idx("d", 8).gen();
+ auto rhs = GS(2.0).idx("b", 8).idx("c", 8).idx("d", 8).gen();
benchmark_join("dense partial overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(DenseJoin, subset_overlap) {
- auto lhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::idx("c", 16), 1.0);
- auto rhs_inner = make_matrix(D::idx("b", 16), D::idx("c", 16), 2.0);
- auto rhs_outer = make_matrix(D::idx("a", 16), D::idx("b", 16), 3.0);
+ auto lhs = GS(1.0).idx("a", 16).idx("b", 16).idx("c", 16).gen();
+ auto rhs_inner = GS(2.0).idx("b", 16).idx("c", 16).gen();
+ auto rhs_outer = GS(3.0).idx("a", 16).idx("b", 16).gen();
benchmark_join("dense subset overlap inner multiply", lhs, rhs_inner, operation::Mul::f);
benchmark_join("dense subset overlap outer multiply", lhs, rhs_outer, operation::Mul::f);
}
TEST(DenseJoin, no_overlap) {
- auto lhs = make_cube(D::idx("a", 4), D::idx("e", 4), D::idx("f", 4), 1.0);
- auto rhs = make_cube(D::idx("b", 4), D::idx("c", 4), D::idx("d", 4), 2.0);
+ auto lhs = GS(1.0).idx("a", 4).idx("e", 4).idx("f", 4).gen();
+ auto rhs = GS(2.0).idx("b", 4).idx("c", 4).idx("d", 4).gen();
benchmark_join("dense no overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(DenseJoin, simple_expand) {
- auto lhs = make_cube(D::idx("a", 5), D::idx("b", 4), D::idx("c", 4), 1.0);
- auto rhs = make_cube(D::idx("d", 4), D::idx("e", 4), D::idx("f", 5), 2.0);
+ auto lhs = GS(1.0).idx("a", 5).idx("b", 4).idx("c", 4).gen();
+ auto rhs = GS(2.0).idx("d", 4).idx("e", 4).idx("f", 5).gen();
benchmark_join("dense simple expand multiply", lhs, rhs, operation::Mul::f);
}
TEST(DenseJoin, multiply_by_number) {
- auto lhs = make_spec(3.0);
- auto rhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::idx("c", 16), 2.0);
+ auto lhs = GS(3.0).gen();
+ auto rhs = GS(2.0).idx("a", 16).idx("b", 16).idx("c", 16).gen();
benchmark_join("dense cube multiply by number", lhs, rhs, operation::Mul::f);
}
//-----------------------------------------------------------------------------
TEST(SparseJoin, small_vectors) {
- auto lhs = make_vector(D::map("x", 10, 1), 1.0);
- auto rhs = make_vector(D::map("x", 10, 2), 2.0);
+ auto lhs = GS(1.0).map("x", 10, 1).gen();
+ auto rhs = GS(2.0).map("x", 10, 2).gen();
benchmark_join("small sparse vector multiply", lhs, rhs, operation::Mul::f);
}
TEST(SparseJoin, large_vectors) {
- auto lhs = make_vector(D::map("x", 1800, 1), 1.0);
- auto rhs = make_vector(D::map("x", 1000, 2), 2.0);
+ auto lhs = GS(1.0).map("x", 1800, 1).gen();
+ auto rhs = GS(2.0).map("x", 1000, 2).gen();
benchmark_join("large sparse vector multiply", lhs, rhs, operation::Mul::f);
}
TEST(SparseJoin, full_overlap) {
- auto lhs = make_cube(D::map("a", 16, 1), D::map("b", 16, 1), D::map("c", 16, 1), 1.0);
- auto rhs = make_cube(D::map("a", 16, 2), D::map("b", 16, 2), D::map("c", 16, 2), 2.0);
+ auto lhs = GS(1.0).map("a", 16, 1).map("b", 16, 1).map("c", 16, 1).gen();
+ auto rhs = GS(2.0).map("a", 16, 2).map("b", 16, 2).map("c", 16, 2).gen();
benchmark_join("sparse full overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(SparseJoin, full_overlap_big_vs_small) {
- auto lhs = make_cube(D::map("a", 16, 1), D::map("b", 16, 1), D::map("c", 16, 1), 1.0);
- auto rhs = make_cube(D::map("a", 2, 1), D::map("b", 2, 1), D::map("c", 2, 1), 2.0);
+ auto lhs = GS(1.0).map("a", 16, 1).map("b", 16, 1).map("c", 16, 1).gen();
+ auto rhs = GS(2.0).map("a", 2, 1).map("b", 2, 1).map("c", 2, 1).gen();
benchmark_join("sparse full overlap big vs small multiply", lhs, rhs, operation::Mul::f);
}
TEST(SparseJoin, partial_overlap) {
- auto lhs = make_cube(D::map("a", 8, 1), D::map("c", 8, 1), D::map("d", 8, 1), 1.0);
- auto rhs = make_cube(D::map("b", 8, 2), D::map("c", 8, 2), D::map("d", 8, 2), 2.0);
+ auto lhs = GS(1.0).map("a", 8, 1).map("c", 8, 1).map("d", 8, 1).gen();
+ auto rhs = GS(2.0).map("b", 8, 2).map("c", 8, 2).map("d", 8, 2).gen();
benchmark_join("sparse partial overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(SparseJoin, no_overlap) {
- auto lhs = make_cube(D::map("a", 4, 1), D::map("e", 4, 1), D::map("f", 4, 1), 1.0);
- auto rhs = make_cube(D::map("b", 4, 1), D::map("c", 4, 1), D::map("d", 4, 1), 2.0);
+ auto lhs = GS(1.0).map("a", 4, 1).map("e", 4, 1).map("f", 4, 1).gen();
+ auto rhs = GS(2.0).map("b", 4, 1).map("c", 4, 1).map("d", 4, 1).gen();
benchmark_join("sparse no overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(SparseJoin, multiply_by_number) {
- auto lhs = make_spec(3.0);
- auto rhs = make_cube(D::map("a", 16, 2), D::map("b", 16, 2), D::map("c", 16, 2), 2.0);
+ auto lhs = GS(3.0).gen();
+ auto rhs = GS(2.0).map("a", 16, 2).map("b", 16, 2).map("c", 16, 2).gen();
benchmark_join("sparse multiply by number", lhs, rhs, operation::Mul::f);
}
//-----------------------------------------------------------------------------
TEST(MixedJoin, full_overlap) {
- auto lhs = make_cube(D::map("a", 16, 1), D::map("b", 16, 1), D::idx("c", 16), 1.0);
- auto rhs = make_cube(D::map("a", 16, 2), D::map("b", 16, 2), D::idx("c", 16), 2.0);
+ auto lhs = GS(1.0).map("a", 16, 1).map("b", 16, 1).idx("c", 16).gen();
+ auto rhs = GS(2.0).map("a", 16, 2).map("b", 16, 2).idx("c", 16).gen();
benchmark_join("mixed full overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(MixedJoin, partial_sparse_overlap) {
- auto lhs = make_cube(D::map("a", 8, 1), D::map("c", 8, 1), D::idx("d", 8), 1.0);
- auto rhs = make_cube(D::map("b", 8, 2), D::map("c", 8, 2), D::idx("d", 8), 2.0);
+ auto lhs = GS(1.0).map("a", 8, 1).map("c", 8, 1).idx("d", 8).gen();
+ auto rhs = GS(2.0).map("b", 8, 2).map("c", 8, 2).idx("d", 8).gen();
benchmark_join("mixed partial sparse overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(MixedJoin, no_overlap) {
- auto lhs = make_cube(D::map("a", 4, 1), D::map("e", 4, 1), D::idx("f", 4), 1.0);
- auto rhs = make_cube(D::map("b", 4, 1), D::map("c", 4, 1), D::idx("d", 4), 2.0);
+ auto lhs = GS(1.0).map("a", 4, 1).map("e", 4, 1).idx("f", 4).gen();
+ auto rhs = GS(2.0).map("b", 4, 1).map("c", 4, 1).idx("d", 4).gen();
benchmark_join("mixed no overlap multiply", lhs, rhs, operation::Mul::f);
}
TEST(MixedJoin, multiply_by_number) {
- auto lhs = make_spec(3.0);
- auto rhs = make_cube(D::map("a", 16, 2), D::map("b", 16, 2), D::idx("c", 16), 2.0);
+ auto lhs = GS(3.0).gen();
+ auto rhs = GS(2.0).map("a", 16, 2).map("b", 16, 2).idx("c", 16).gen();
benchmark_join("mixed multiply by number", lhs, rhs, operation::Mul::f);
}
//-----------------------------------------------------------------------------
TEST(ReduceBench, number_reduce) {
- auto lhs = make_spec(1.0);
+ auto lhs = GS(1.0).gen();
benchmark_reduce("number reduce", lhs, Aggr::SUM, {});
}
TEST(ReduceBench, dense_reduce) {
- auto lhs = make_cube(D::idx("a", 16), D::idx("b", 16), D::idx("c", 16), 1.0);
+ auto lhs = GS(1.0).idx("a", 16).idx("b", 16).idx("c", 16).gen();
benchmark_reduce("dense reduce inner", lhs, Aggr::SUM, {"c"});
benchmark_reduce("dense reduce middle", lhs, Aggr::SUM, {"b"});
benchmark_reduce("dense reduce outer", lhs, Aggr::SUM, {"a"});
@@ -929,7 +886,7 @@ TEST(ReduceBench, dense_reduce) {
}
TEST(ReduceBench, sparse_reduce) {
- auto lhs = make_cube(D::map("a", 16, 1), D::map("b", 16, 1), D::map("c", 16, 1), 1.0);
+ auto lhs = GS(1.0).map("a", 16, 1).map("b", 16, 1).map("c", 16, 1).gen();
benchmark_reduce("sparse reduce inner", lhs, Aggr::SUM, {"c"});
benchmark_reduce("sparse reduce middle", lhs, Aggr::SUM, {"b"});
benchmark_reduce("sparse reduce outer", lhs, Aggr::SUM, {"a"});
@@ -940,8 +897,8 @@ TEST(ReduceBench, sparse_reduce) {
}
TEST(ReduceBench, mixed_reduce) {
- auto lhs = make_spec(1.0, D::map("a", 4, 1), D::map("b", 4, 1), D::map("c", 4, 1),
- D::idx("d", 4), D::idx("e", 4), D::idx("f", 4));
+ auto lhs = GS(1.0).map("a", 4, 1).map("b", 4, 1).map("c", 4, 1)
+ .idx("d", 4).idx("e", 4).idx("f", 4).gen();
benchmark_reduce("mixed reduce middle dense", lhs, Aggr::SUM, {"e"});
benchmark_reduce("mixed reduce middle sparse", lhs, Aggr::SUM, {"b"});
benchmark_reduce("mixed reduce middle sparse/dense", lhs, Aggr::SUM, {"b", "e"});
@@ -953,87 +910,87 @@ TEST(ReduceBench, mixed_reduce) {
//-----------------------------------------------------------------------------
TEST(RenameBench, dense_rename) {
- auto lhs = make_matrix(D::idx("a", 64), D::idx("b", 64), 1.0);
+ auto lhs = GS(1.0).idx("a", 64).idx("b", 64).gen();
benchmark_rename("dense transpose", lhs, {"a", "b"}, {"b", "a"});
}
TEST(RenameBench, sparse_rename) {
- auto lhs = make_matrix(D::map("a", 64, 1), D::map("b", 64, 1), 1.0);
+ auto lhs = GS(1.0).map("a", 64, 1).map("b", 64, 1).gen();
benchmark_rename("sparse transpose", lhs, {"a", "b"}, {"b", "a"});
}
TEST(RenameBench, mixed_rename) {
- auto lhs = make_spec(1.0, D::map("a", 8, 1), D::map("b", 8, 1), D::idx("c", 8), D::idx("d", 8));
+ auto lhs = GS(1.0).map("a", 8, 1).map("b", 8, 1).idx("c", 8).idx("d", 8).gen();
benchmark_rename("mixed multi-transpose", lhs, {"a", "b", "c", "d"}, {"b", "a", "d", "c"});
}
//-----------------------------------------------------------------------------
TEST(MergeBench, dense_merge) {
- auto lhs = make_matrix(D::idx("a", 64), D::idx("b", 64), 1.0);
- auto rhs = make_matrix(D::idx("a", 64), D::idx("b", 64), 2.0);
+ auto lhs = GS(1.0).idx("a", 64).idx("b", 64).gen();
+ auto rhs = GS(2.0).idx("a", 64).idx("b", 64).gen();
benchmark_merge("dense merge", lhs, rhs, operation::Max::f);
}
TEST(MergeBench, sparse_merge_big_small) {
- auto lhs = make_matrix(D::map("a", 64, 1), D::map("b", 64, 1), 1.0);
- auto rhs = make_matrix(D::map("a", 8, 1), D::map("b", 8, 1), 2.0);
+ auto lhs = GS(1.0).map("a", 64, 1).map("b", 64, 1).gen();
+ auto rhs = GS(2.0).map("a", 8, 1).map("b", 8, 1).gen();
benchmark_merge("sparse merge big vs small", lhs, rhs, operation::Max::f);
}
TEST(MergeBench, sparse_merge_minimal_overlap) {
- auto lhs = make_matrix(D::map("a", 64, 11), D::map("b", 32, 11), 1.0);
- auto rhs = make_matrix(D::map("a", 32, 13), D::map("b", 64, 13), 2.0);
+ auto lhs = GS(1.0).map("a", 64, 11).map("b", 32, 11).gen();
+ auto rhs = GS(2.0).map("a", 32, 13).map("b", 64, 13).gen();
benchmark_merge("sparse merge minimal overlap", lhs, rhs, operation::Max::f);
}
TEST(MergeBench, mixed_merge) {
- auto lhs = make_matrix(D::map("a", 64, 1), D::idx("b", 64), 1.0);
- auto rhs = make_matrix(D::map("a", 64, 2), D::idx("b", 64), 2.0);
+ auto lhs = GS(1.0).map("a", 64, 1).idx("b", 64).gen();
+ auto rhs = GS(2.0).map("a", 64, 2).idx("b", 64).gen();
benchmark_merge("mixed merge", lhs, rhs, operation::Max::f);
}
//-----------------------------------------------------------------------------
TEST(MapBench, number_map) {
- auto lhs = make_spec(1.75);
+ auto lhs = GS(1.75).gen();
benchmark_map("number map", lhs, operation::Floor::f);
}
TEST(MapBench, dense_map) {
- auto lhs = make_matrix(D::idx("a", 64), D::idx("b", 64), 1.75);
+ auto lhs = GS(1.75).idx("a", 64).idx("b", 64).gen();
benchmark_map("dense map", lhs, operation::Floor::f);
}
TEST(MapBench, sparse_map_small) {
- auto lhs = make_matrix(D::map("a", 4, 1), D::map("b", 4, 1), 1.75);
+ auto lhs = GS(1.75).map("a", 4, 1).map("b", 4, 1).gen();
benchmark_map("sparse map small", lhs, operation::Floor::f);
}
TEST(MapBench, sparse_map_big) {
- auto lhs = make_matrix(D::map("a", 64, 1), D::map("b", 64, 1), 1.75);
+ auto lhs = GS(1.75).map("a", 64, 1).map("b", 64, 1).gen();
benchmark_map("sparse map big", lhs, operation::Floor::f);
}
TEST(MapBench, mixed_map) {
- auto lhs = make_matrix(D::map("a", 64, 1), D::idx("b", 64), 1.75);
+ auto lhs = GS(1.75).map("a", 64, 1).idx("b", 64).gen();
benchmark_map("mixed map", lhs, operation::Floor::f);
}
//-----------------------------------------------------------------------------
TEST(TensorCreateBench, create_dense) {
- auto proto = make_matrix(D::idx("a", 32), D::idx("b", 32), 1.0);
+ auto proto = GS(1.0).idx("a", 32).idx("b", 32).gen();
benchmark_tensor_create("dense tensor create", proto);
}
TEST(TensorCreateBench, create_sparse) {
- auto proto = make_matrix(D::map("a", 32, 1), D::map("b", 32, 1), 1.0);
+ auto proto = GS(1.0).map("a", 32, 1).map("b", 32, 1).gen();
benchmark_tensor_create("sparse tensor create", proto);
}
TEST(TensorCreateBench, create_mixed) {
- auto proto = make_matrix(D::map("a", 32, 1), D::idx("b", 32), 1.0);
+ auto proto = GS(1.0).map("a", 32, 1).idx("b", 32).gen();
benchmark_tensor_create("mixed tensor create", proto);
}
@@ -1041,7 +998,7 @@ TEST(TensorCreateBench, create_mixed) {
TEST(TensorLambdaBench, simple_lambda) {
auto type = ValueType::from_spec("tensor<float>(a[64],b[64])");
- auto p0 = make_spec(3.5);
+ auto p0 = GS(3.5).gen();
auto function = Function::parse({"a", "b", "p0"}, "(a*64+b)*p0");
ASSERT_FALSE(function->has_error());
benchmark_tensor_lambda("simple tensor lambda", type, p0, *function);
@@ -1049,7 +1006,7 @@ TEST(TensorLambdaBench, simple_lambda) {
TEST(TensorLambdaBench, complex_lambda) {
auto type = ValueType::from_spec("tensor<float>(a[64],b[64])");
- auto p0 = make_vector(D::idx("x", 3), 1.0);
+ auto p0 = GS(1.0).idx("x", 3).gen();
auto function = Function::parse({"a", "b", "p0"}, "(a*64+b)*reduce(p0,sum)");
ASSERT_FALSE(function->has_error());
benchmark_tensor_lambda("complex tensor lambda", type, p0, *function);
@@ -1058,7 +1015,7 @@ TEST(TensorLambdaBench, complex_lambda) {
//-----------------------------------------------------------------------------
TEST(TensorPeekBench, dense_peek) {
- auto lhs = make_matrix(D::idx("a", 64), D::idx("b", 64), 1.0);
+ auto lhs = GS(1.0).idx("a", 64).idx("b", 64).gen();
benchmark_tensor_peek("dense peek cell verbatim", lhs, verbatim_peek().add("a", 1).add("b", 2));
benchmark_tensor_peek("dense peek cell dynamic", lhs, dynamic_peek().add("a", 1).add("b", 2));
benchmark_tensor_peek("dense peek vector verbatim", lhs, verbatim_peek().add("a", 1));
@@ -1066,7 +1023,7 @@ TEST(TensorPeekBench, dense_peek) {
}
TEST(TensorPeekBench, sparse_peek) {
- auto lhs = make_matrix(D::map("a", 64, 1), D::map("b", 64, 1), 1.0);
+ auto lhs = GS(1.0).map("a", 64, 1).map("b", 64, 1).gen();
benchmark_tensor_peek("sparse peek cell verbatim", lhs, verbatim_peek().add("a", 1).add("b", 2));
benchmark_tensor_peek("sparse peek cell dynamic", lhs, dynamic_peek().add("a", 1).add("b", 2));
benchmark_tensor_peek("sparse peek vector verbatim", lhs, verbatim_peek().add("a", 1));
@@ -1074,7 +1031,7 @@ TEST(TensorPeekBench, sparse_peek) {
}
TEST(TensorPeekBench, mixed_peek) {
- auto lhs = make_spec(1.0, D::map("a", 8, 1), D::map("b", 8, 1), D::idx("c", 8), D::idx("d", 8));
+ auto lhs = GS(1.0).map("a", 8, 1).map("b", 8, 1).idx("c", 8).idx("d", 8).gen();
benchmark_tensor_peek("mixed peek cell verbatim", lhs, verbatim_peek().add("a", 1).add("b", 2).add("c", 3).add("d", 4));
benchmark_tensor_peek("mixed peek cell dynamic", lhs, dynamic_peek().add("a", 1).add("b", 2).add("c", 3).add("d", 4));
benchmark_tensor_peek("mixed peek dense verbatim", lhs, verbatim_peek().add("a", 1).add("b", 2));