From 3da6a0e3dd242d2b0cd359f164ccf3691633f00c Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Thu, 3 Dec 2020 21:29:45 +0000 Subject: remove immediate API --- .../generic_concat/generic_concat_test.cpp | 19 ----------- .../instruction/generic_join/generic_join_test.cpp | 21 ------------ .../instruction/generic_map/generic_map_test.cpp | 20 ------------ .../generic_merge/generic_merge_test.cpp | 21 ------------ .../generic_reduce/generic_reduce_test.cpp | 23 ------------- .../generic_rename/generic_rename_test.cpp | 25 -------------- eval/src/vespa/eval/instruction/generic_concat.cpp | 20 ------------ eval/src/vespa/eval/instruction/generic_concat.h | 5 --- eval/src/vespa/eval/instruction/generic_join.cpp | 21 ------------ eval/src/vespa/eval/instruction/generic_join.h | 4 --- eval/src/vespa/eval/instruction/generic_map.cpp | 38 ---------------------- eval/src/vespa/eval/instruction/generic_map.h | 4 --- eval/src/vespa/eval/instruction/generic_merge.cpp | 21 ------------ eval/src/vespa/eval/instruction/generic_merge.h | 4 --- eval/src/vespa/eval/instruction/generic_reduce.cpp | 19 ----------- eval/src/vespa/eval/instruction/generic_reduce.h | 5 --- eval/src/vespa/eval/instruction/generic_rename.cpp | 22 ------------- eval/src/vespa/eval/instruction/generic_rename.h | 6 ---- 18 files changed, 298 deletions(-) (limited to 'eval') diff --git a/eval/src/tests/instruction/generic_concat/generic_concat_test.cpp b/eval/src/tests/instruction/generic_concat/generic_concat_test.cpp index b5ff2ec3b48..cfecdb97aa0 100644 --- a/eval/src/tests/instruction/generic_concat/generic_concat_test.cpp +++ b/eval/src/tests/instruction/generic_concat/generic_concat_test.cpp @@ -110,24 +110,5 @@ TEST(GenericConcatTest, dense_concat_plan_can_be_created) { EXPECT_EQ(plan.right.out_stride, expect_right_out_s); } -TensorSpec immediate_generic_concat(const TensorSpec &a, const TensorSpec &b, const std::string &concat_dim) { - const auto &factory = SimpleValueBuilderFactory::get(); - auto lhs = value_from_spec(a, factory); - auto rhs = value_from_spec(b, factory); - auto up = GenericConcat::perform_concat(*lhs, *rhs, concat_dim, factory); - return spec_from_value(*up); -} - -TEST(GenericConcatTest, immediate_generic_concat_works) { - ASSERT_TRUE((concat_layouts.size() % 2) == 0); - for (size_t i = 0; i < concat_layouts.size(); i += 2) { - const TensorSpec lhs = spec(concat_layouts[i], N()); - const TensorSpec rhs = spec(concat_layouts[i + 1], Div16(N())); - SCOPED_TRACE(fmt("\n===\nin LHS: %s\nin RHS: %s\n===\n", lhs.to_string().c_str(), rhs.to_string().c_str())); - auto actual = immediate_generic_concat(lhs, rhs, "y"); - auto expect = ReferenceOperations::concat(lhs, rhs, "y"); - EXPECT_EQ(actual, expect); - } -} GTEST_MAIN_RUN_ALL_TESTS() diff --git a/eval/src/tests/instruction/generic_join/generic_join_test.cpp b/eval/src/tests/instruction/generic_join/generic_join_test.cpp index a81294c8d25..f4046b3d059 100644 --- a/eval/src/tests/instruction/generic_join/generic_join_test.cpp +++ b/eval/src/tests/instruction/generic_join/generic_join_test.cpp @@ -123,26 +123,5 @@ TEST(GenericJoinTest, generic_join_works_for_simple_and_fast_values) { } } -TensorSpec immediate_generic_join(const TensorSpec &a, const TensorSpec &b, join_fun_t function) { - const auto &factory = SimpleValueBuilderFactory::get(); - auto lhs = value_from_spec(a, factory); - auto rhs = value_from_spec(b, factory); - auto up = GenericJoin::perform_join(*lhs, *rhs, function, factory); - return spec_from_value(*up); -} - -TEST(GenericJoinTest, immediate_generic_join_works) { - ASSERT_TRUE((join_layouts.size() % 2) == 0); - for (size_t i = 0; i < join_layouts.size(); i += 2) { - TensorSpec lhs = spec(join_layouts[i], Div16(N())); - TensorSpec rhs = spec(join_layouts[i + 1], Div16(N())); - for (auto fun: {operation::Add::f, operation::Sub::f, operation::Mul::f, operation::Div::f}) { - SCOPED_TRACE(fmt("\n===\nLHS: %s\nRHS: %s\n===\n", lhs.to_string().c_str(), rhs.to_string().c_str())); - auto expect = ReferenceOperations::join(lhs, rhs, fun); - auto actual = immediate_generic_join(lhs, rhs, fun); - EXPECT_EQ(actual, expect); - } - } -} GTEST_MAIN_RUN_ALL_TESTS() diff --git a/eval/src/tests/instruction/generic_map/generic_map_test.cpp b/eval/src/tests/instruction/generic_map/generic_map_test.cpp index ba6a1630777..687b6aa60ac 100644 --- a/eval/src/tests/instruction/generic_map/generic_map_test.cpp +++ b/eval/src/tests/instruction/generic_map/generic_map_test.cpp @@ -60,24 +60,4 @@ TEST(GenericMapTest, generic_map_works_for_fast_values) { test_generic_map_with(FastValueBuilderFactory::get()); } -TensorSpec immediate_generic_map(const TensorSpec &a, map_fun_t func, const ValueBuilderFactory &factory) -{ - auto lhs = value_from_spec(a, factory); - auto up = GenericMap::perform_map(*lhs, func, factory); - return spec_from_value(*up); -} - -TEST(GenericMapTest, immediate_generic_map_works) { - for (const auto & layout : map_layouts) { - TensorSpec lhs = spec(layout, Div16(N())); - ValueType lhs_type = ValueType::from_spec(lhs.type()); - for (auto func : {operation::Floor::f, operation::Fabs::f, operation::Square::f, operation::Inv::f}) { - SCOPED_TRACE(fmt("\n===\nLHS: %s\n===\n", lhs.to_string().c_str())); - auto expect = ReferenceOperations::map(lhs, func); - auto actual = immediate_generic_map(lhs, func, SimpleValueBuilderFactory::get()); - EXPECT_EQ(actual, expect); - } - } -} - GTEST_MAIN_RUN_ALL_TESTS() diff --git a/eval/src/tests/instruction/generic_merge/generic_merge_test.cpp b/eval/src/tests/instruction/generic_merge/generic_merge_test.cpp index a43169a6959..60a27e6f6e9 100644 --- a/eval/src/tests/instruction/generic_merge/generic_merge_test.cpp +++ b/eval/src/tests/instruction/generic_merge/generic_merge_test.cpp @@ -65,26 +65,5 @@ TEST(GenericMergeTest, generic_merge_works_for_fast_values) { test_generic_merge_with(FastValueBuilderFactory::get()); } -TensorSpec immediate_generic_merge(const TensorSpec &a, const TensorSpec &b, join_fun_t fun) { - const auto &factory = SimpleValueBuilderFactory::get(); - auto lhs = value_from_spec(a, factory); - auto rhs = value_from_spec(b, factory); - auto up = GenericMerge::perform_merge(*lhs, *rhs, fun, factory); - return spec_from_value(*up); -} - -TEST(GenericMergeTest, immediate_generic_merge_works) { - ASSERT_TRUE((merge_layouts.size() % 2) == 0); - for (size_t i = 0; i < merge_layouts.size(); i += 2) { - TensorSpec lhs = spec(merge_layouts[i], N()); - TensorSpec rhs = spec(merge_layouts[i + 1], Div16(N())); - SCOPED_TRACE(fmt("\n===\nLHS: %s\nRHS: %s\n===\n", lhs.to_string().c_str(), rhs.to_string().c_str())); - for (auto fun: {operation::Add::f, operation::Mul::f, operation::Sub::f, operation::Max::f}) { - auto expect = ReferenceOperations::merge(lhs, rhs, fun); - auto actual = immediate_generic_merge(lhs, rhs, fun); - EXPECT_EQ(actual, expect); - } - } -} GTEST_MAIN_RUN_ALL_TESTS() diff --git a/eval/src/tests/instruction/generic_reduce/generic_reduce_test.cpp b/eval/src/tests/instruction/generic_reduce/generic_reduce_test.cpp index 273c69a395d..3ab971dd34d 100644 --- a/eval/src/tests/instruction/generic_reduce/generic_reduce_test.cpp +++ b/eval/src/tests/instruction/generic_reduce/generic_reduce_test.cpp @@ -90,28 +90,5 @@ TEST(GenericReduceTest, generic_reduce_works_for_fast_values) { test_generic_reduce_with(FastValueBuilderFactory::get()); } -TensorSpec immediate_generic_reduce(const TensorSpec &a, Aggr aggr, const std::vector &dims) { - const auto &factory = SimpleValueBuilderFactory::get(); - auto lhs = value_from_spec(a, factory); - auto up = GenericReduce::perform_reduce(*lhs, aggr, dims, factory); - return spec_from_value(*up); -} - -TEST(GenericReduceTest, immediate_generic_reduce_works) { - for (const Layout &layout: layouts) { - TensorSpec input = spec(layout, Div16(N())); - for (Aggr aggr: {Aggr::SUM, Aggr::AVG, Aggr::MIN, Aggr::MAX}) { - for (const Domain &domain: layout) { - auto expect = ReferenceOperations::reduce(input, aggr, {domain.dimension}).normalize(); - auto actual = immediate_generic_reduce(input, aggr, {domain.dimension}); - EXPECT_EQ(actual, expect); - } - auto expect = ReferenceOperations::reduce(input, aggr, {}).normalize(); - auto actual = immediate_generic_reduce(input, aggr, {}); - EXPECT_EQ(actual, expect); - } - } -} - GTEST_MAIN_RUN_ALL_TESTS() diff --git a/eval/src/tests/instruction/generic_rename/generic_rename_test.cpp b/eval/src/tests/instruction/generic_rename/generic_rename_test.cpp index a7e6b8d807b..20d155822b5 100644 --- a/eval/src/tests/instruction/generic_rename/generic_rename_test.cpp +++ b/eval/src/tests/instruction/generic_rename/generic_rename_test.cpp @@ -134,29 +134,4 @@ TEST(GenericRenameTest, generic_rename_works_for_fast_values) { test_generic_rename_with(FastValueBuilderFactory::get()); } -TensorSpec immediate_generic_rename(const TensorSpec &a, const FromTo &ft) -{ - auto &factory = SimpleValueBuilderFactory::get(); - auto lhs = value_from_spec(a, factory); - auto up = GenericRename::perform_rename(*lhs, ft.from, ft.to, factory); - return spec_from_value(*up); -} - -TEST(GenericRenameTest, immediate_generic_rename_works) { - for (const auto & layout : rename_layouts) { - TensorSpec lhs = spec(layout, N()); - ValueType lhs_type = ValueType::from_spec(lhs.type()); - // printf("lhs_type: %s\n", lhs_type.to_spec().c_str()); - for (const auto & from_to : rename_from_to) { - ValueType renamed_type = lhs_type.rename(from_to.from, from_to.to); - if (renamed_type.is_error()) continue; - // printf("type %s -> %s\n", lhs_type.to_spec().c_str(), renamed_type.to_spec().c_str()); - SCOPED_TRACE(fmt("\n===\nLHS: %s\n===\n", lhs.to_string().c_str())); - auto expect = ReferenceOperations::rename(lhs, from_to.from, from_to.to); - auto actual = immediate_generic_rename(lhs, from_to); - EXPECT_EQ(actual, expect); - } - } -} - GTEST_MAIN_RUN_ALL_TESTS() diff --git a/eval/src/vespa/eval/instruction/generic_concat.cpp b/eval/src/vespa/eval/instruction/generic_concat.cpp index 7a2280c5db7..2d8c206b588 100644 --- a/eval/src/vespa/eval/instruction/generic_concat.cpp +++ b/eval/src/vespa/eval/instruction/generic_concat.cpp @@ -121,15 +121,6 @@ struct SelectGenericConcatOp { } }; -struct PerformGenericConcat { - template - static auto invoke(const Value &a, const Value &b, const ConcatParam ¶m) { - return generic_concat(a, b, - param.sparse_plan, param.dense_plan, - param.res_type, param.factory); - } -}; - enum class Case { NONE, OUT, CONCAT, BOTH }; } // namespace @@ -219,15 +210,4 @@ GenericConcat::make_instruction(const ValueType &lhs_type, const ValueType &rhs_ return Instruction(fun, wrap_param(param)); } -Value::UP -GenericConcat::perform_concat(const Value &a, const Value &b, - const vespalib::string &dimension, - const ValueBuilderFactory &factory) -{ - ConcatParam param(a.type(), b.type(), dimension, factory); - return typify_invoke<3,TypifyCellType,PerformGenericConcat>( - a.type().cell_type(), b.type().cell_type(), param.res_type.cell_type(), - a, b, param); -} - } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_concat.h b/eval/src/vespa/eval/instruction/generic_concat.h index d41d161900a..5578c5a0dca 100644 --- a/eval/src/vespa/eval/instruction/generic_concat.h +++ b/eval/src/vespa/eval/instruction/generic_concat.h @@ -17,11 +17,6 @@ struct GenericConcat { make_instruction(const ValueType &lhs_type, const ValueType &rhs_type, const vespalib::string &dimension, const ValueBuilderFactory &factory, Stash &stash); - - static Value::UP - perform_concat(const Value &a, const Value &b, - const vespalib::string &dimension, - const ValueBuilderFactory &factory); }; struct DenseConcatPlan { diff --git a/eval/src/vespa/eval/instruction/generic_join.cpp b/eval/src/vespa/eval/instruction/generic_join.cpp index 25829576ba5..026df5aa993 100644 --- a/eval/src/vespa/eval/instruction/generic_join.cpp +++ b/eval/src/vespa/eval/instruction/generic_join.cpp @@ -195,16 +195,6 @@ struct SelectGenericJoinOp { } }; -struct PerformGenericJoin { - template - static auto invoke(const Value &a, const Value &b, const JoinParam ¶m) - { - return generic_mixed_join(a, b, param); - } -}; - - - //----------------------------------------------------------------------------- } // namespace @@ -327,15 +317,4 @@ GenericJoin::make_instruction(const ValueType &lhs_type, const ValueType &rhs_ty return Instruction(fun, wrap_param(param)); } - -Value::UP -GenericJoin::perform_join(const Value &a, const Value &b, join_fun_t function, - const ValueBuilderFactory &factory) -{ - JoinParam param(a.type(), b.type(), function, factory); - return typify_invoke<4,JoinTypify,PerformGenericJoin>( - a.type().cell_type(), b.type().cell_type(), param.res_type.cell_type(), function, - a, b, param); -} - } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_join.h b/eval/src/vespa/eval/instruction/generic_join.h index 49cdb3499a9..e5ddf388211 100644 --- a/eval/src/vespa/eval/instruction/generic_join.h +++ b/eval/src/vespa/eval/instruction/generic_join.h @@ -21,10 +21,6 @@ struct GenericJoin { make_instruction(const ValueType &lhs_type, const ValueType &rhs_type, join_fun_t function, const ValueBuilderFactory &factory, Stash &stash); - - static Value::UP - perform_join(const Value &a, const Value &b, join_fun_t function, - const ValueBuilderFactory &factory); }; //----------------------------------------------------------------------------- diff --git a/eval/src/vespa/eval/instruction/generic_map.cpp b/eval/src/vespa/eval/instruction/generic_map.cpp index 993f0a45925..8ad6c3ee68b 100644 --- a/eval/src/vespa/eval/instruction/generic_map.cpp +++ b/eval/src/vespa/eval/instruction/generic_map.cpp @@ -48,36 +48,6 @@ struct SelectGenericMapOp { } }; -struct PerformGenericMap { - template - static auto invoke(const Value &input, map_fun_t function_in, - const ValueBuilderFactory &factory) - { - Func fun(function_in); - const auto &type = input.type(); - size_t subspace_size = type.dense_subspace_size(); - size_t num_mapped = type.count_mapped_dimensions(); - auto builder = factory.create_value_builder(type, num_mapped, subspace_size, input.index().size()); - auto input_cells = input.cells().typify(); - auto view = input.index().create_view({}); - std::vector output_address(num_mapped); - std::vector input_address; - for (auto & label : output_address) { - input_address.push_back(&label); - } - view->lookup({}); - size_t subspace; - while (view->next_result(input_address, subspace)) { - auto dst = builder->add_subspace(output_address); - size_t input_offset = subspace_size * subspace; - for (size_t i = 0; i < subspace_size; ++i) { - dst[i] = fun(input_cells[input_offset + i]); - } - } - return builder->build(std::move(builder)); - } -}; - } // namespace using MapTypify = TypifyValue; @@ -89,12 +59,4 @@ GenericMap::make_instruction(const ValueType &lhs_type, map_fun_t function) return Instruction(op, to_param(function)); } -Value::UP -GenericMap::perform_map(const Value &a, map_fun_t function, - const ValueBuilderFactory &factory) -{ - return typify_invoke<2,MapTypify,PerformGenericMap>(a.type().cell_type(), function, - a, function, factory); -} - } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_map.h b/eval/src/vespa/eval/instruction/generic_map.h index 9c8fb17c153..ad29d2c1073 100644 --- a/eval/src/vespa/eval/instruction/generic_map.h +++ b/eval/src/vespa/eval/instruction/generic_map.h @@ -15,10 +15,6 @@ using map_fun_t = vespalib::eval::operation::op1_t; struct GenericMap { static InterpretedFunction::Instruction make_instruction(const ValueType &input_type, map_fun_t function); - - static Value::UP - perform_map(const Value &a, map_fun_t function, - const ValueBuilderFactory &factory); }; } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_merge.cpp b/eval/src/vespa/eval/instruction/generic_merge.cpp index 8de4ea1adeb..02749a04eb9 100644 --- a/eval/src/vespa/eval/instruction/generic_merge.cpp +++ b/eval/src/vespa/eval/instruction/generic_merge.cpp @@ -156,13 +156,6 @@ struct SelectGenericMergeOp { } }; -struct PerformGenericMerge { - template - static auto invoke(const Value &a, const Value &b, const MergeParam ¶m) { - return generic_mixed_merge(a, b, param); - } -}; - //----------------------------------------------------------------------------- } // namespace @@ -178,18 +171,4 @@ GenericMerge::make_instruction(const ValueType &lhs_type, const ValueType &rhs_t return Instruction(fun, wrap_param(param)); } - -Value::UP -GenericMerge::perform_merge(const Value &a, const Value &b, join_fun_t function, - const ValueBuilderFactory &factory) -{ - MergeParam param(a.type(), b.type(), function, factory); - return typify_invoke<4,MergeTypify,PerformGenericMerge>( - a.type().cell_type(), - b.type().cell_type(), - param.res_type.cell_type(), function, - a, b, param); -} - - } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_merge.h b/eval/src/vespa/eval/instruction/generic_merge.h index e9ffcc87997..2b2964366cc 100644 --- a/eval/src/vespa/eval/instruction/generic_merge.h +++ b/eval/src/vespa/eval/instruction/generic_merge.h @@ -11,10 +11,6 @@ struct GenericMerge { make_instruction(const ValueType &lhs_type, const ValueType &rhs_type, join_fun_t function, const ValueBuilderFactory &factory, Stash &stash); - - static Value::UP - perform_merge(const Value &a, const Value &b, join_fun_t function, - const ValueBuilderFactory &factory); }; } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_reduce.cpp b/eval/src/vespa/eval/instruction/generic_reduce.cpp index 9b2e72e45db..ad4692c2e80 100644 --- a/eval/src/vespa/eval/instruction/generic_reduce.cpp +++ b/eval/src/vespa/eval/instruction/generic_reduce.cpp @@ -153,13 +153,6 @@ struct SelectGenericReduceOp { } }; -struct PerformGenericReduce { - template - static auto invoke(const Value &input, const ReduceParam ¶m) { - return generic_reduce>(input, param); - } -}; - //----------------------------------------------------------------------------- } // namespace @@ -248,16 +241,4 @@ GenericReduce::make_instruction(const ValueType &type, Aggr aggr, const std::vec return Instruction(fun, wrap_param(param)); } - -Value::UP -GenericReduce::perform_reduce(const Value &a, Aggr aggr, - const std::vector &dimensions, - const ValueBuilderFactory &factory) -{ - ReduceParam param(a.type(), dimensions, factory); - return typify_invoke<3,ReduceTypify,PerformGenericReduce>( - a.type().cell_type(), param.res_type.cell_type(), aggr, - a, param); -} - } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_reduce.h b/eval/src/vespa/eval/instruction/generic_reduce.h index cacc0f4cfd3..f753a3e51cd 100644 --- a/eval/src/vespa/eval/instruction/generic_reduce.h +++ b/eval/src/vespa/eval/instruction/generic_reduce.h @@ -41,11 +41,6 @@ struct GenericReduce { make_instruction(const ValueType &type, Aggr aggr, const std::vector &dimensions, const ValueBuilderFactory &factory, Stash &stash); - - static Value::UP - perform_reduce(const Value &a, Aggr aggr, - const std::vector &dimensions, - const ValueBuilderFactory &factory); }; //----------------------------------------------------------------------------- diff --git a/eval/src/vespa/eval/instruction/generic_rename.cpp b/eval/src/vespa/eval/instruction/generic_rename.cpp index 3d8de356001..1ce18597ec2 100644 --- a/eval/src/vespa/eval/instruction/generic_rename.cpp +++ b/eval/src/vespa/eval/instruction/generic_rename.cpp @@ -107,14 +107,6 @@ struct SelectGenericRenameOp { } }; -struct PerformGenericRename { - template - static auto invoke(const Value &a, const RenameParam ¶m) { - return generic_rename(a, param.sparse_plan, param.dense_plan, - param.res_type, param.factory); - } -}; - } // namespace //----------------------------------------------------------------------------- @@ -194,19 +186,5 @@ GenericRename::make_instruction(const ValueType &lhs_type, return Instruction(fun, wrap_param(param)); } - -Value::UP -GenericRename::perform_rename(const Value &a, - const std::vector &rename_dimension_from, - const std::vector &rename_dimension_to, - const ValueBuilderFactory &factory) -{ - RenameParam param(a.type(), - rename_dimension_from, rename_dimension_to, - factory); - return typify_invoke<1,TypifyCellType,PerformGenericRename>(a.type().cell_type(), - a, param); -} - } // namespace diff --git a/eval/src/vespa/eval/instruction/generic_rename.h b/eval/src/vespa/eval/instruction/generic_rename.h index 4088e817b90..6c94ff02b24 100644 --- a/eval/src/vespa/eval/instruction/generic_rename.h +++ b/eval/src/vespa/eval/instruction/generic_rename.h @@ -44,12 +44,6 @@ struct GenericRename { const std::vector &rename_dimension_from, const std::vector &rename_dimension_to, const ValueBuilderFactory &factory, Stash &stash); - - static Value::UP - perform_rename(const Value &a, - const std::vector &rename_dimension_from, - const std::vector &rename_dimension_to, - const ValueBuilderFactory &factory); }; } // namespace -- cgit v1.2.3