diff options
10 files changed, 56 insertions, 58 deletions
diff --git a/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp b/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp index 231fba93d10..067cf4ac649 100644 --- a/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp +++ b/document/src/tests/tensor_fieldvalue/tensor_fieldvalue_test.cpp @@ -9,16 +9,13 @@ LOG_SETUP("fieldvalue_test"); #include <vespa/document/fieldvalue/tensorfieldvalue.h> #include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/eval/value.h> -#include <vespa/eval/tensor/test/test_utils.h> #include <vespa/vespalib/testkit/testapp.h> using namespace document; -using namespace vespalib::tensor; using vespalib::eval::TensorSpec; using vespalib::eval::ValueType; using vespalib::eval::EngineOrFactory; -using vespalib::tensor::test::makeTensor; namespace { @@ -33,8 +30,8 @@ vespalib::eval::Value::UP createTensor(const TensorSpec &spec) { std::unique_ptr<vespalib::eval::Value> makeSimpleTensor() { - return makeTensor<vespalib::eval::Value>(TensorSpec("tensor(x{},y{})"). - add({{"x", "4"}, {"y", "5"}}, 7)); + return EngineOrFactory::get().from_spec(TensorSpec("tensor(x{},y{})"). + add({{"x", "4"}, {"y", "5"}}, 7)); } FieldValue::UP clone(FieldValue &fv) { diff --git a/document/src/vespa/document/update/tensor_add_update.cpp b/document/src/vespa/document/update/tensor_add_update.cpp index 3ae599f22a0..d71ab7d922c 100644 --- a/document/src/vespa/document/update/tensor_add_update.cpp +++ b/document/src/vespa/document/update/tensor_add_update.cpp @@ -11,7 +11,6 @@ #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/tensor/partial_update.h> -#include <vespa/eval/tensor/tensor.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/stringfmt.h> diff --git a/document/src/vespa/document/update/tensor_modify_update.cpp b/document/src/vespa/document/update/tensor_modify_update.cpp index 2ff45b11b07..970550b7c88 100644 --- a/document/src/vespa/document/update/tensor_modify_update.cpp +++ b/document/src/vespa/document/update/tensor_modify_update.cpp @@ -12,8 +12,6 @@ #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/tensor/partial_update.h> -#include <vespa/eval/tensor/tensor.h> -#include <vespa/eval/tensor/cell_values.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/stringfmt.h> diff --git a/document/src/vespa/document/update/tensor_remove_update.cpp b/document/src/vespa/document/update/tensor_remove_update.cpp index 688f9cf5399..f04728e95a4 100644 --- a/document/src/vespa/document/update/tensor_remove_update.cpp +++ b/document/src/vespa/document/update/tensor_remove_update.cpp @@ -8,9 +8,6 @@ #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/tensor/partial_update.h> -#include <vespa/eval/tensor/tensor.h> -#include <vespa/eval/tensor/cell_values.h> -#include <vespa/eval/tensor/sparse/sparse_tensor.h> #include <vespa/eval/eval/value.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/xmlstream.h> diff --git a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp index 58b7838bf35..6c7efda9a69 100644 --- a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp +++ b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp @@ -48,7 +48,6 @@ #include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/test/value_compare.h> -#include <vespa/eval/tensor/types.h> #include <vespa/vespalib/data/slime/slime.h> using document::Annotation; diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index c28a099a990..ed3bb3253c9 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -5,8 +5,9 @@ #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/update/documentupdate.h> +#include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> -#include <vespa/eval/tensor/test/test_utils.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/searchcore/proton/test/bucketfactory.h> #include <vespa/searchcore/proton/common/feedtoken.h> @@ -57,10 +58,10 @@ using storage::spi::UpdateResult; using vespalib::ThreadStackExecutor; using vespalib::ThreadStackExecutorBase; using vespalib::makeClosure; +using vespalib::eval::EngineOrFactory; using vespalib::eval::TensorSpec; using vespalib::eval::Value; using vespalib::eval::ValueType; -using vespalib::tensor::test::makeTensor; using namespace proton; using namespace search::index; @@ -329,13 +330,13 @@ struct UpdateContext { auto fieldValue = field.createValue(); if (fieldName == "tensor") { dynamic_cast<TensorFieldValue &>(*fieldValue) = - makeTensor<Value>(TensorSpec("tensor(x{},y{})"). - add({{"x","8"},{"y","9"}}, 11)); + EngineOrFactory::get().from_spec(TensorSpec("tensor(x{},y{})"). + add({{"x","8"},{"y","9"}}, 11)); } else if (fieldName == "tensor2") { auto tensorFieldValue = std::make_unique<TensorFieldValue>(tensor1DType); *tensorFieldValue = - makeTensor<Value>(TensorSpec("tensor(x{})"). - add({{"x","8"}}, 11)); + EngineOrFactory::get().from_spec(TensorSpec("tensor(x{})"). + add({{"x","8"}}, 11)); fieldValue = std::move(tensorFieldValue); } else { fieldValue->assign(document::StringFieldValue("new value")); diff --git a/searchcore/src/tests/proton/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp index ee9388e2141..019e1bce40a 100644 --- a/searchcore/src/tests/proton/server/documentretriever_test.cpp +++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp @@ -23,7 +23,6 @@ #include <vespa/eval/eval/engine_or_factory.h> #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/test/value_compare.h> -#include <vespa/eval/tensor/test/test_utils.h> #include <vespa/persistence/spi/bucket.h> #include <vespa/persistence/spi/test.h> #include <vespa/searchcommon/common/schema.h> @@ -93,7 +92,6 @@ using vespalib::eval::EngineOrFactory; using vespalib::eval::TensorSpec; using vespalib::eval::ValueType; using vespalib::eval::Value; -using vespalib::tensor::test::makeTensor; using namespace document::config_builder; using namespace search::index; @@ -112,8 +110,10 @@ const char dyn_field_nas[] = "dynamic null attr string field"; // in document, n const char position_field[] = "position_field"; vespalib::string dyn_field_tensor("dynamic_tensor_field"); vespalib::string tensor_spec("tensor(x{})"); -std::unique_ptr<Value> static_tensor = makeTensor<Value>(TensorSpec(tensor_spec).add({{"x", "1"}}, 1.5)); -std::unique_ptr<Value> dynamic_tensor = makeTensor<Value>(TensorSpec(tensor_spec).add({{"x", "2"}}, 3.5)); +std::unique_ptr<Value> static_tensor = + EngineOrFactory::get().from_spec(TensorSpec(tensor_spec).add({{"x", "1"}}, 1.5)); +std::unique_ptr<Value> dynamic_tensor = + EngineOrFactory::get().from_spec(TensorSpec(tensor_spec).add({{"x", "2"}}, 3.5)); const char zcurve_field[] = "position_field_zcurve"; const char position_array_field[] = "position_array"; const char zcurve_array_field[] = "position_array_zcurve"; diff --git a/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp b/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp index 3a755704c0d..ec6aa65c6c2 100644 --- a/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp +++ b/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp @@ -7,8 +7,8 @@ #include <vespa/searchlib/fef/test/rankresult.h> #include <vespa/searchlib/fef/test/dummy_dependency_handler.h> #include <vespa/eval/eval/engine_or_factory.h> +#include <vespa/eval/eval/value_codec.h> #include <vespa/vespalib/objects/nbostream.h> -#include <vespa/eval/tensor/dense/dense_tensor.h> using namespace search; using namespace search::attribute; @@ -17,6 +17,8 @@ using namespace search::fef; using namespace search::fef::test; using namespace search::index; +using vespalib::eval::TensorSpec; + template <typename T> std::unique_ptr<fef::Anything> create_param(const vespalib::string& param) { Properties props; @@ -109,12 +111,18 @@ struct ArrayFixture : FixtureBase { template <typename ExpectedType> void check_prepare_state_output(const vespalib::eval::Value & tensor, const ExpectedType & expected) { vespalib::nbostream os; - vespalib::eval::EngineOrFactory::get().encode(tensor, os); + encode_value(tensor, os); vespalib::string input_vector(os.data(), os.size()); check_prepare_state_output(".tensor", input_vector, expected); } template <typename ExpectedType> + void check_prepare_state_output(const TensorSpec & spec, const ExpectedType & expected) { + auto value = vespalib::eval::EngineOrFactory::get().from_spec(spec); + check_prepare_state_output(*value, expected); + } + + template <typename ExpectedType> void check_prepare_state_output(const vespalib::string& input_vector, const ExpectedType & expected) { check_prepare_state_output("", input_vector, expected); } @@ -196,25 +204,25 @@ TEST_F("prepareSharedState emits double vector for double imported attribute", A TEST_F("prepareSharedState handles tensor as float from tensor for double imported attribute", ArrayFixture) { f.setup_float_mappings(BasicType::DOUBLE); - vespalib::tensor::DenseTensor<float> tensor(vespalib::eval::ValueType::from_spec("tensor<float>(x[3])"), {10.1, 20.2, 30.3}); + auto tensor = TensorSpec::from_expr("tensor<float>(x[3]):[10.1,20.2,30.3]"); f.template check_prepare_state_output(tensor, dotproduct::ArrayParam<double>({10.1, 20.2, 30.3})); } TEST_F("prepareSharedState handles tensor as double from tensor for double imported attribute", ArrayFixture) { f.setup_float_mappings(BasicType::DOUBLE); - vespalib::tensor::DenseTensor<double> tensor(vespalib::eval::ValueType::from_spec("tensor(x[3])"), {10.1, 20.2, 30.3}); + auto tensor = TensorSpec::from_expr("tensor(x[3]):[10.1,20.2,30.3]"); f.template check_prepare_state_output(tensor, dotproduct::ArrayParam<double>({10.1, 20.2, 30.3})); } TEST_F("prepareSharedState handles tensor as float from tensor for float imported attribute", ArrayFixture) { f.setup_float_mappings(BasicType::FLOAT); - vespalib::tensor::DenseTensor<float> tensor(vespalib::eval::ValueType::from_spec("tensor<float>(x[3])"), {10.1, 20.2, 30.3}); + auto tensor = TensorSpec::from_expr("tensor<float>(x[3]):[10.1,20.2,30.3]"); f.template check_prepare_state_output(tensor, dotproduct::ArrayParam<float>({10.1, 20.2, 30.3})); } TEST_F("prepareSharedState handles tensor as double from tensor for float imported attribute", ArrayFixture) { f.setup_float_mappings(BasicType::FLOAT); - vespalib::tensor::DenseTensor<double> tensor(vespalib::eval::ValueType::from_spec("tensor(x[3])"), {10.1, 20.2, 30.3}); + auto tensor = TensorSpec::from_expr("tensor(x[3]):[10.1,20.2,30.3]"); f.template check_prepare_state_output(tensor, dotproduct::ArrayParam<float>({10.1, 20.2, 30.3})); } diff --git a/searchlib/src/tests/features/tensor/tensor_test.cpp b/searchlib/src/tests/features/tensor/tensor_test.cpp index 116b4ed2bb5..188a1347901 100644 --- a/searchlib/src/tests/features/tensor/tensor_test.cpp +++ b/searchlib/src/tests/features/tensor/tensor_test.cpp @@ -15,8 +15,8 @@ #include <vespa/eval/eval/function.h> #include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> +#include <vespa/eval/eval/value_codec.h> #include <vespa/eval/eval/test/value_compare.h> -#include <vespa/eval/tensor/test/test_utils.h> #include <vespa/vespalib/objects/nbostream.h> using search::feature_t; @@ -30,10 +30,10 @@ using search::tensor::DirectTensorAttribute; using search::AttributeVector; using vespalib::eval::EngineOrFactory; using vespalib::eval::Function; +using vespalib::eval::spec_from_value; using vespalib::eval::Value; using vespalib::eval::ValueType; using vespalib::eval::TensorSpec; -using vespalib::tensor::test::makeTensor; using AVC = search::attribute::Config; using AVBT = search::attribute::BasicType; @@ -113,10 +113,10 @@ struct ExecFixture DirectTensorAttribute *directAttr = dynamic_cast<DirectTensorAttribute *>(attrs[1].get()); - auto doc_tensor = makeTensor<Value>(TensorSpec("tensor(x{})") - .add({{"x", "a"}}, 3) - .add({{"x", "b"}}, 5) - .add({{"x", "c"}}, 7)); + auto doc_tensor = EngineOrFactory::get().from_spec(TensorSpec("tensor(x{})") + .add({{"x", "a"}}, 3) + .add({{"x", "b"}}, 5) + .add({{"x", "c"}}, 7)); tensorAttr->setTensor(1, *doc_tensor); directAttr->set_tensor(1, std::move(doc_tensor)); @@ -138,16 +138,16 @@ struct ExecFixture void setupQueryEnvironment() { setQueryTensor("tensorquery", "tensor(q{})", - makeTensor<Value>(TensorSpec("tensor(q{})") - .add({{"q", "d"}}, 11 ) - .add({{"q", "e"}}, 13 ) - .add({{"q", "f"}}, 17 ))); + EngineOrFactory::get().from_spec(TensorSpec("tensor(q{})") + .add({{"q", "d"}}, 11 ) + .add({{"q", "e"}}, 13 ) + .add({{"q", "f"}}, 17 ))); setQueryTensor("mappedtensorquery", "tensor(x[2])", - makeTensor<Value>(TensorSpec("tensor(x{},y{})") - .add({{"x", "0"},{"y", "0"}}, 11 ) - .add({{"x", "0"},{"y", "1"}}, 13 ) - .add({{"x", "1"},{"y", "0"}}, 17 ))); + EngineOrFactory::get().from_spec(TensorSpec("tensor(x{},y{})") + .add({{"x", "0"},{"y", "0"}}, 11 ) + .add({{"x", "0"},{"y", "1"}}, 13 ) + .add({{"x", "1"},{"y", "0"}}, 17 ))); setQueryTensorType("null", "tensor(q{})"); } const Value &extractTensor(uint32_t docid) { @@ -163,28 +163,28 @@ struct ExecFixture TEST_F("require that tensor attribute can be extracted as tensor in attribute feature", ExecFixture("attribute(tensorattr)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(x{})") - .add({{"x", "b"}}, 5) - .add({{"x", "c"}}, 7) - .add({{"x", "a"}}, 3)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(x{})") + .add({{"x", "b"}}, 5) + .add({{"x", "c"}}, 7) + .add({{"x", "a"}}, 3), spec_from_value(f.execute())); } TEST_F("require that direct tensor attribute can be extracted in attribute feature", ExecFixture("attribute(directattr)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(x{})") - .add({{"x", "b"}}, 5) - .add({{"x", "c"}}, 7) - .add({{"x", "a"}}, 3)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(x{})") + .add({{"x", "b"}}, 5) + .add({{"x", "c"}}, 7) + .add({{"x", "a"}}, 3), spec_from_value(f.execute())); } TEST_F("require that tensor from query can be extracted as tensor in query feature", ExecFixture("query(tensorquery)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(q{})") - .add({{"q", "f"}}, 17) - .add({{"q", "d"}}, 11) - .add({{"q", "e"}}, 13)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(q{})") + .add({{"q", "f"}}, 17) + .add({{"q", "d"}}, 11) + .add({{"q", "e"}}, 13), spec_from_value(f.execute())); } TEST_F("require that empty tensor is created if attribute does not exists", @@ -217,9 +217,9 @@ TEST_F("require that empty tensor with correct type is returned by direct tensor TEST_F("require that wrong tensor type from query tensor gives empty tensor", ExecFixture("query(mappedtensorquery)")) { - EXPECT_EQUAL(*makeTensor<Value>(TensorSpec("tensor(x[2])") - .add({{"x", 0}}, 0) - .add({{"x", 1}}, 0)), f.execute()); + EXPECT_EQUAL(TensorSpec("tensor(x[2])") + .add({{"x", 0}}, 0) + .add({{"x", 1}}, 0), spec_from_value(f.execute())); } TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/vespa/searchlib/tensor/direct_tensor_saver.cpp b/searchlib/src/vespa/searchlib/tensor/direct_tensor_saver.cpp index e67d5d8202b..9e0163d610f 100644 --- a/searchlib/src/vespa/searchlib/tensor/direct_tensor_saver.cpp +++ b/searchlib/src/vespa/searchlib/tensor/direct_tensor_saver.cpp @@ -4,7 +4,6 @@ #include "direct_tensor_store.h" #include <vespa/eval/eval/engine_or_factory.h> -#include <vespa/eval/tensor/serialization/typed_binary_format.h> #include <vespa/searchlib/attribute/iattributesavetarget.h> #include <vespa/searchlib/util/bufferwriter.h> #include <vespa/vespalib/objects/nbostream.h> |