summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com>2020-06-15 14:45:40 +0200
committerGitHub <noreply@github.com>2020-06-15 14:45:40 +0200
commitbcb5baef1f3bbf3c29aec4e07f385ee10c0598c9 (patch)
treec7e9c784a99bfe671291043e712d18fd21c81b67
parent2a0c1eff754c5182c4ccebef88f63e9467d7ef00 (diff)
parent52827742ddc5af98db91a45dedabaabed55f521c (diff)
Merge pull request #13584 from vespa-engine/arnej/stop-using-dispatch-0
use typify_invoke instead of dispatch_0/select_2
-rw-r--r--eval/src/vespa/eval/tensor/default_tensor_engine.cpp10
-rw-r--r--eval/src/vespa/eval/tensor/serialization/dense_binary_format.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp6
4 files changed, 15 insertions, 11 deletions
diff --git a/eval/src/vespa/eval/tensor/default_tensor_engine.cpp b/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
index d9fcbaa3e2a..22073143ac0 100644
--- a/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
+++ b/eval/src/vespa/eval/tensor/default_tensor_engine.cpp
@@ -176,7 +176,7 @@ DefaultTensorEngine::to_spec(const Value &value) const
struct CallDenseTensorBuilder {
template <typename CT>
static Value::UP
- call(const ValueType &type, const TensorSpec &spec)
+ invoke(const ValueType &type, const TensorSpec &spec)
{
TypedDenseTensorBuilder<CT> builder(type);
for (const auto &cell: spec.cells()) {
@@ -191,6 +191,8 @@ struct CallDenseTensorBuilder {
}
};
+using MyTypify = eval::TypifyCellType;
+
Value::UP
DefaultTensorEngine::from_spec(const TensorSpec &spec) const
{
@@ -201,7 +203,7 @@ DefaultTensorEngine::from_spec(const TensorSpec &spec) const
double value = spec.cells().empty() ? 0.0 : spec.cells().begin()->second.value;
return std::make_unique<DoubleValue>(value);
} else if (type.is_dense()) {
- return dispatch_0<CallDenseTensorBuilder>(type.cell_type(), type, spec);
+ return typify_invoke<1,MyTypify,CallDenseTensorBuilder>(type.cell_type(), type, spec);
} else if (type.is_sparse()) {
DirectSparseTensorBuilder builder(type);
SparseTensorAddressBuilder address_builder;
@@ -449,7 +451,7 @@ const Value &concat_vectors(const Value &a, const Value &b, const vespalib::stri
struct CallConcatVectors {
template <typename OCT>
- static const Value &call(const Value &a, const Value &b, const vespalib::string &dimension, size_t vector_size, Stash &stash) {
+ static const Value &invoke(const Value &a, const Value &b, const vespalib::string &dimension, size_t vector_size, Stash &stash) {
return concat_vectors<OCT>(a, b, dimension, vector_size, stash);
}
};
@@ -461,7 +463,7 @@ DefaultTensorEngine::concat(const Value &a, const Value &b, const vespalib::stri
size_t b_size = vector_size(b.type(), dimension);
if ((a_size > 0) && (b_size > 0)) {
CellType result_cell_type = ValueType::unify_cell_types(a.type(), b.type());
- return dispatch_0<CallConcatVectors>(result_cell_type, a, b, dimension, (a_size + b_size), stash);
+ return typify_invoke<1,MyTypify,CallConcatVectors>(result_cell_type, a, b, dimension, (a_size + b_size), stash);
}
return to_default(simple_engine().concat(to_simple(a, stash), to_simple(b, stash), dimension, stash), stash);
}
diff --git a/eval/src/vespa/eval/tensor/serialization/dense_binary_format.cpp b/eval/src/vespa/eval/tensor/serialization/dense_binary_format.cpp
index 493e4af3caf..4d6cfb1c9af 100644
--- a/eval/src/vespa/eval/tensor/serialization/dense_binary_format.cpp
+++ b/eval/src/vespa/eval/tensor/serialization/dense_binary_format.cpp
@@ -92,7 +92,7 @@ DenseBinaryFormat::serialize(nbostream &stream, const DenseTensorView &tensor)
struct CallDecodeCells {
template <typename CT>
static std::unique_ptr<DenseTensorView>
- call(nbostream &stream, size_t numCells, ValueType &&newType) {
+ invoke(nbostream &stream, size_t numCells, ValueType &&newType) {
std::vector<CT> newCells;
newCells.reserve(numCells);
decodeCells<CT>(stream, numCells, newCells);
@@ -106,7 +106,8 @@ DenseBinaryFormat::deserialize(nbostream &stream, CellType cell_type)
std::vector<Dimension> dimensions;
size_t numCells = decodeDimensions(stream, dimensions);
ValueType newType = ValueType::tensor_type(std::move(dimensions), cell_type);
- return dispatch_0<CallDecodeCells>(cell_type, stream, numCells, std::move(newType));
+ using MyTypify = eval::TypifyCellType;
+ return typify_invoke<1,MyTypify,CallDecodeCells>(cell_type, stream, numCells, std::move(newType));
}
template <typename T>
diff --git a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp
index 55342f91e93..d8b63909142 100644
--- a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp
@@ -45,7 +45,7 @@ convert_cells<double,double>(std::unique_ptr<DenseTensorView> &, vespalib::eval:
struct ConvertCellsSelector
{
template <typename LCT, typename RCT>
- static auto get_fun() { return convert_cells<LCT, RCT>; }
+ static auto invoke() { return convert_cells<LCT, RCT>; }
};
} // namespace <unnamed>
@@ -67,7 +67,8 @@ NearestNeighborBlueprint::NearestNeighborBlueprint(const queryeval::FieldSpec& f
{
auto lct = _query_tensor->cellsRef().type;
auto rct = _attr_tensor.getTensorType().cell_type();
- auto fixup_fun = vespalib::tensor::select_2<ConvertCellsSelector>(lct, rct);
+ using MyTypify = vespalib::eval::TypifyCellType;
+ auto fixup_fun = vespalib::typify_invoke<2,MyTypify,ConvertCellsSelector>(lct, rct);
fixup_fun(_query_tensor, _attr_tensor.getTensorType());
_fallback_dist_fun = search::tensor::make_distance_function(_attr_tensor.getConfig().distance_metric(), rct);
_dist_fun = _fallback_dist_fun.get();
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
index 979eedec58a..f8db11ae9d8 100644
--- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp
@@ -20,7 +20,6 @@ using vespalib::tensor::SparseTensor;
using vespalib::tensor::Tensor;
using vespalib::tensor::TypedDenseTensorBuilder;
using vespalib::tensor::WrappedSimpleTensor;
-using vespalib::tensor::dispatch_0;
using search::StateExplorerUtils;
namespace search::tensor {
@@ -34,7 +33,7 @@ constexpr size_t DEAD_SLACK = 0x10000u;
struct CallMakeEmptyTensor {
template <typename CT>
- static Tensor::UP call(const ValueType &type) {
+ static Tensor::UP invoke(const ValueType &type) {
TypedDenseTensorBuilder<CT> builder(type);
return builder.build();
}
@@ -46,7 +45,8 @@ createEmptyTensor(const ValueType &type)
if (type.is_sparse()) {
return std::make_unique<SparseTensor>(type, SparseTensor::Cells());
} else if (type.is_dense()) {
- return dispatch_0<CallMakeEmptyTensor>(type.cell_type(), type);
+ using MyTypify = vespalib::eval::TypifyCellType;
+ return vespalib::typify_invoke<1,MyTypify,CallMakeEmptyTensor>(type.cell_type(), type);
} else {
return std::make_unique<WrappedSimpleTensor>(std::make_unique<SimpleTensor>(type, SimpleTensor::Cells()));
}