summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2021-03-03 14:38:29 +0000
committerHåvard Pettersen <havardpe@oath.com>2021-03-04 18:34:31 +0000
commitd48fc6fd919be1a21ca19165b6ddfa6171791725 (patch)
treea915ae22221dc955b98914496f43a80eb4ff62cf /searchlib
parent311e77aad06f187c70864a80a0703082f72bb3d8 (diff)
all scalars must be double
and all operation results must be at least float
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/features/constant/constant_test.cpp4
-rw-r--r--searchlib/src/tests/features/tensor/tensor_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/configconverter.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/features/attributefeature.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/features/queryfeature.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h3
-rw-r--r--searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp11
8 files changed, 22 insertions, 18 deletions
diff --git a/searchlib/src/tests/features/constant/constant_test.cpp b/searchlib/src/tests/features/constant/constant_test.cpp
index 140c93125b0..9c8480c1da2 100644
--- a/searchlib/src/tests/features/constant/constant_test.cpp
+++ b/searchlib/src/tests/features/constant/constant_test.cpp
@@ -45,7 +45,7 @@ struct ExecFixture
bool setup() { return test.setup(); }
const Value &extractTensor(uint32_t docid) {
Value::CREF value = test.resolveObjectFeature(docid);
- ASSERT_TRUE(value.get().is_tensor());
+ ASSERT_TRUE(value.get().type().has_dimensions());
return value.get();
}
const Value &executeTensor(uint32_t docId = 1) {
@@ -53,7 +53,7 @@ struct ExecFixture
}
double extractDouble(uint32_t docid) {
Value::CREF value = test.resolveObjectFeature(docid);
- ASSERT_TRUE(value.get().is_double());
+ ASSERT_TRUE(value.get().type().is_double());
return value.get().as_double();
}
double executeDouble(uint32_t docId = 1) {
diff --git a/searchlib/src/tests/features/tensor/tensor_test.cpp b/searchlib/src/tests/features/tensor/tensor_test.cpp
index 53049c4a385..5d7698822eb 100644
--- a/searchlib/src/tests/features/tensor/tensor_test.cpp
+++ b/searchlib/src/tests/features/tensor/tensor_test.cpp
@@ -152,7 +152,7 @@ struct ExecFixture
}
const Value &extractTensor(uint32_t docid) {
Value::CREF value = test.resolveObjectFeature(docid);
- ASSERT_TRUE(value.get().is_tensor());
+ ASSERT_TRUE(value.get().type().has_dimensions());
return value.get();
}
const Value &execute(uint32_t docId = 1) {
diff --git a/searchlib/src/vespa/searchlib/attribute/configconverter.cpp b/searchlib/src/vespa/searchlib/attribute/configconverter.cpp
index f2e2f8271de..991f1f03ee7 100644
--- a/searchlib/src/vespa/searchlib/attribute/configconverter.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/configconverter.cpp
@@ -11,6 +11,7 @@ namespace {
using search::attribute::CollectionType;
using search::attribute::BasicType;
using vespalib::eval::ValueType;
+using vespalib::eval::CellType;
typedef std::map<AttributesConfig::Attribute::Datatype, BasicType::Type> DataTypeMap;
typedef std::map<AttributesConfig::Attribute::Collectiontype, CollectionType::Type> CollectionTypeMap;
@@ -102,7 +103,7 @@ ConfigConverter::convert(const AttributesConfig::Attribute & cfg)
if (!cfg.tensortype.empty()) {
retval.setTensorType(ValueType::from_spec(cfg.tensortype));
} else {
- retval.setTensorType(ValueType::tensor_type({}));
+ retval.setTensorType(ValueType::double_type());
}
}
return retval;
diff --git a/searchlib/src/vespa/searchlib/features/attributefeature.cpp b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
index 80d9a305ef4..2c1ae7c557a 100644
--- a/searchlib/src/vespa/searchlib/features/attributefeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/attributefeature.cpp
@@ -530,7 +530,7 @@ AttributeBlueprint::setup(const fef::IIndexEnvironment & env,
"the given key of a weighted set attribute, or"
"the tensor of a tensor attribute", output_type);
const fef::FieldInfo * fInfo = env.getFieldByName(_attrName);
- if (_tensorType.is_tensor() || isSingleValueBoolField(*fInfo)) {
+ if (_tensorType.has_dimensions() || isSingleValueBoolField(*fInfo)) {
_numOutputs = 1;
} else {
describeOutput("weight", "The weight associated with the given key in a weighted set attribute.");
@@ -558,7 +558,7 @@ fef::FeatureExecutor &
AttributeBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const
{
const IAttributeVector * attribute = lookupAttribute(_attrKey, _attrName, env);
- if (_tensorType.is_tensor()) {
+ if (_tensorType.has_dimensions()) {
return createTensorAttributeExecutor(attribute, _attrName, _tensorType, stash);
} else {
return createAttributeExecutor(_numOutputs, attribute, _attrName, _extra, stash);
diff --git a/searchlib/src/vespa/searchlib/features/queryfeature.cpp b/searchlib/src/vespa/searchlib/features/queryfeature.cpp
index c6196fcbc7f..60bd77e4883 100644
--- a/searchlib/src/vespa/searchlib/features/queryfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/queryfeature.cpp
@@ -137,7 +137,7 @@ createTensorExecutor(const IQueryEnvironment &env,
FeatureExecutor &
QueryBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Stash &stash) const
{
- if (_valueType.is_tensor()) {
+ if (_valueType.has_dimensions()) {
return createTensorExecutor(env, _key, _valueType, stash);
} else {
std::vector<feature_t> values;
diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h b/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h
index f4a5b0b8d0a..475075671cd 100644
--- a/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h
+++ b/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h
@@ -8,6 +8,7 @@
#include <vespa/vespalib/stllike/string.h>
using vespalib::eval::FastValueBuilderFactory;
+using vespalib::eval::CellType;
namespace search::features {
@@ -29,7 +30,7 @@ public:
TensorFromAttributeExecutor(const search::attribute::IAttributeVector *attribute,
const vespalib::string &dimension)
: _attribute(attribute),
- _type(vespalib::eval::ValueType::tensor_type({{dimension}})),
+ _type(vespalib::eval::ValueType::make_type(CellType::DOUBLE, {{dimension}})),
_attrBuffer(),
_addr_ref(),
_tensor()
diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp b/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp
index e4f0a010ae2..76a6e908fcb 100644
--- a/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp
+++ b/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.cpp
@@ -20,6 +20,7 @@ using search::attribute::WeightedConstCharContent;
using search::attribute::WeightedStringContent;
using vespalib::eval::FastValueBuilderFactory;
using vespalib::eval::ValueType;
+using vespalib::eval::CellType;
using search::fef::FeatureType;
namespace search {
@@ -45,7 +46,7 @@ TensorFromLabelsBlueprint::setup(const search::fef::IIndexEnvironment &env,
}
describeOutput("tensor",
"The tensor created from the given array source (attribute field or query parameter)",
- FeatureType::object(ValueType::tensor_type({{_dimension}})));
+ FeatureType::object(ValueType::make_type(CellType::DOUBLE, {{_dimension}})));
return validSource;
}
@@ -60,13 +61,13 @@ createAttributeExecutor(const search::fef::IQueryEnvironment &env,
if (attribute == NULL) {
LOG(warning, "The attribute vector '%s' was not found in the attribute manager."
" Returning empty tensor.", attrName.c_str());
- return ConstantTensorExecutor::createEmpty(ValueType::tensor_type({{dimension}}), stash);
+ return ConstantTensorExecutor::createEmpty(ValueType::make_type(CellType::DOUBLE, {{dimension}}), stash);
}
if (attribute->getCollectionType() != search::attribute::CollectionType::ARRAY ||
attribute->isFloatingPointType()) {
LOG(warning, "The attribute vector '%s' is NOT of type array of string or integer."
" Returning empty tensor.", attrName.c_str());
- return ConstantTensorExecutor::createEmpty(ValueType::tensor_type({{dimension}}), stash);
+ return ConstantTensorExecutor::createEmpty(ValueType::make_type(CellType::DOUBLE, {{dimension}}), stash);
}
// Note that for array attribute vectors the default weight is 1.0 for all values.
// This means we can get the attribute content as weighted content and build
@@ -86,7 +87,7 @@ createQueryExecutor(const search::fef::IQueryEnvironment &env,
const vespalib::string &queryKey,
const vespalib::string &dimension, vespalib::Stash &stash)
{
- ValueType type = ValueType::tensor_type({{dimension}});
+ ValueType type = ValueType::make_type(CellType::DOUBLE, {{dimension}});
search::fef::Property prop = env.getProperties().lookup(queryKey);
if (prop.found() && !prop.get().empty()) {
std::vector<vespalib::string> vector;
@@ -115,7 +116,7 @@ TensorFromLabelsBlueprint::createExecutor(const search::fef::IQueryEnvironment &
} else if (_sourceType == QUERY_SOURCE) {
return createQueryExecutor(env, _sourceParam, _dimension, stash);
}
- return ConstantTensorExecutor::createEmpty(ValueType::tensor_type({{_dimension}}), stash);
+ return ConstantTensorExecutor::createEmpty(ValueType::make_type(CellType::DOUBLE, {{_dimension}}), stash);
}
} // namespace features
diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp
index 88309120882..50fab518402 100644
--- a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp
+++ b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.cpp
@@ -21,6 +21,7 @@ using search::attribute::WeightedConstCharContent;
using search::attribute::WeightedStringContent;
using vespalib::eval::FastValueBuilderFactory;
using vespalib::eval::ValueType;
+using vespalib::eval::CellType;
using search::fef::FeatureType;
namespace search {
@@ -58,7 +59,7 @@ TensorFromWeightedSetBlueprint::setup(const search::fef::IIndexEnvironment &env,
}
describeOutput("tensor",
"The tensor created from the given weighted set source (attribute field or query parameter)",
- FeatureType::object(ValueType::tensor_type({{_dimension}})));
+ FeatureType::object(ValueType::make_type(CellType::DOUBLE, {{_dimension}})));
return validSource;
}
@@ -74,13 +75,13 @@ createAttributeExecutor(const search::fef::IQueryEnvironment &env,
if (attribute == NULL) {
LOG(warning, "The attribute vector '%s' was not found in the attribute manager."
" Returning empty tensor.", attrName.c_str());
- return ConstantTensorExecutor::createEmpty(ValueType::tensor_type({{dimension}}), stash);
+ return ConstantTensorExecutor::createEmpty(ValueType::make_type(CellType::DOUBLE, {{dimension}}), stash);
}
if (attribute->getCollectionType() != search::attribute::CollectionType::WSET ||
attribute->isFloatingPointType()) {
LOG(warning, "The attribute vector '%s' is NOT of type weighted set of string or integer."
" Returning empty tensor.", attrName.c_str());
- return ConstantTensorExecutor::createEmpty(ValueType::tensor_type({{dimension}}), stash);
+ return ConstantTensorExecutor::createEmpty(ValueType::make_type(CellType::DOUBLE, {{dimension}}), stash);
}
if (attribute->isIntegerType()) {
// Using WeightedStringContent ensures that the integer values are converted
@@ -97,7 +98,7 @@ createQueryExecutor(const search::fef::IQueryEnvironment &env,
const vespalib::string &queryKey,
const vespalib::string &dimension, vespalib::Stash &stash)
{
- ValueType type = ValueType::tensor_type({{dimension}});
+ ValueType type = ValueType::make_type(CellType::DOUBLE, {{dimension}});
search::fef::Property prop = env.getProperties().lookup(queryKey);
if (prop.found() && !prop.get().empty()) {
WeightedStringVector vector;
@@ -127,7 +128,7 @@ TensorFromWeightedSetBlueprint::createExecutor(const search::fef::IQueryEnvironm
} else if (_sourceType == QUERY_SOURCE) {
return createQueryExecutor(env, _sourceParam, _dimension, stash);
}
- return ConstantTensorExecutor::createEmpty(ValueType::tensor_type({{_dimension}}), stash);
+ return ConstantTensorExecutor::createEmpty(ValueType::make_type(CellType::DOUBLE, {{_dimension}}), stash);
}
} // namespace features