diff options
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/tests/ann/nns-l2.h | 10 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.cpp | 12 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h | 13 |
3 files changed, 14 insertions, 21 deletions
diff --git a/eval/src/tests/ann/nns-l2.h b/eval/src/tests/ann/nns-l2.h index 857866ff73b..82a95741200 100644 --- a/eval/src/tests/ann/nns-l2.h +++ b/eval/src/tests/ann/nns-l2.h @@ -1,7 +1,7 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <string.h> +#include <cstring> #include <vespa/vespalib/util/arrayref.h> #include <vespa/vespalib/hwaccelrated/iaccelrated.h> @@ -34,7 +34,7 @@ static double hw_l2_sq_dist(const T * af, const T * bf, size_t sz) template <typename FltType = float> struct L2DistCalc { - vespalib::hwaccelrated::IAccelrated::UP _hw; + const vespalib::hwaccelrated::IAccelrated & _hw; L2DistCalc() : _hw(vespalib::hwaccelrated::IAccelrated::getAccelrator()) {} @@ -42,16 +42,16 @@ struct L2DistCalc { using ConstArr = vespalib::ConstArrayRef<FltType>; double product(const FltType *v1, const FltType *v2, size_t sz) { - return _hw->dotProduct(v1, v2, sz); + return _hw.dotProduct(v1, v2, sz); } double product(ConstArr v1, ConstArr v2) { const FltType *p1 = v1.begin(); const FltType *p2 = v2.begin(); - return _hw->dotProduct(p1, p2, v1.size()); + return _hw.dotProduct(p1, p2, v1.size()); } double l2sq(ConstArr vector) { const FltType *v = vector.begin(); - return _hw->dotProduct(v, v, vector.size()); + return _hw.dotProduct(v, v, vector.size()); } double l2sq_dist(ConstArr v1, ConstArr v2, Arr tmp) { for (size_t i = 0; i < v1.size(); ++i) { diff --git a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.cpp b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.cpp index 4a28b54d201..c47521e702d 100644 --- a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.cpp +++ b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.cpp @@ -43,18 +43,6 @@ DirectSparseTensorBuilder::build() { return std::make_unique<SparseTensor>(std::move(_type), std::move(_cells), std::move(_stash)); } -void -DirectSparseTensorBuilder::insertCell(SparseTensorAddressRef address, double value) { - // This address should not already exist and a new cell should be inserted. - insertCell(address, value, [](double, double) -> double { HDR_ABORT("should not be reached"); }); -} - -void -DirectSparseTensorBuilder::insertCell(SparseTensorAddressBuilder &address, double value) { - // This address should not already exist and a new cell should be inserted. - insertCell(address.getAddressRef(), value, [](double, double) -> double { HDR_ABORT("should not be reached"); }); -} - void DirectSparseTensorBuilder::reserve(uint32_t estimatedCells) { _cells.resize(estimatedCells*2); } diff --git a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h index f9182a199be..bcb22c0761d 100644 --- a/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h +++ b/eval/src/vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h @@ -45,15 +45,20 @@ public: } } - void insertCell(SparseTensorAddressRef address, double value); + void insertCell(SparseTensorAddressRef address, double value) { + // This address should not already exist and a new cell should be inserted. + insertCell(address, value, [](double, double) -> double { HDR_ABORT("should not be reached"); }); + } template <class Function> - void insertCell(SparseTensorAddressBuilder &address, double value, Function &&func) - { + void insertCell(SparseTensorAddressBuilder &address, double value, Function &&func) { insertCell(address.getAddressRef(), value, func); } - void insertCell(SparseTensorAddressBuilder &address, double value); + void insertCell(SparseTensorAddressBuilder &address, double value) { + // This address should not already exist and a new cell should be inserted. + insertCell(address.getAddressRef(), value, [](double, double) -> double { HDR_ABORT("should not be reached"); }); + } eval::ValueType &fast_type() { return _type; } Cells &cells() { return _cells; } |