diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-06-15 08:12:15 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-06-15 08:12:56 +0000 |
commit | 52827742ddc5af98db91a45dedabaabed55f521c (patch) | |
tree | c22ac9270dfee22868c60eef31d0985b3c9f0c5d /eval/src | |
parent | 136dd71a56d4f60962da508ac3387bfafcdaeca9 (diff) |
use typify_invoke instead of dispatch_0/select_2
Diffstat (limited to 'eval/src')
-rw-r--r-- | eval/src/vespa/eval/tensor/default_tensor_engine.cpp | 10 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/serialization/dense_binary_format.cpp | 5 |
2 files changed, 9 insertions, 6 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> |