diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-04-13 09:37:22 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-04-13 09:37:22 +0000 |
commit | ce76656d6d994179d52641aab577cdd1b83250f1 (patch) | |
tree | 7effd47fa1b06f1e920748e41ac771ed268e464a /searchlib | |
parent | d083381fadef275687e7af2a566acac1b2ebc56b (diff) |
underscore for member variable, more asserts
Diffstat (limited to 'searchlib')
4 files changed, 13 insertions, 7 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/angular_distance.h b/searchlib/src/vespa/searchlib/tensor/angular_distance.h index 2c8643e7747..ce1fa40b2a4 100644 --- a/searchlib/src/vespa/searchlib/tensor/angular_distance.h +++ b/searchlib/src/vespa/searchlib/tensor/angular_distance.h @@ -48,7 +48,9 @@ public: AngularDistanceHW() : AngularDistance(vespalib::eval::get_cell_type<FloatType>()), _computer(vespalib::hwaccelrated::IAccelrated::getAccelerator()) - {} + { + assert(expected_cell_type() == vespalib::eval::get_cell_type<FloatType>()); + } double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { constexpr vespalib::eval::CellType expected = vespalib::eval::get_cell_type<FloatType>(); assert(lhs.type == expected && rhs.type == expected); diff --git a/searchlib/src/vespa/searchlib/tensor/distance_function.h b/searchlib/src/vespa/searchlib/tensor/distance_function.h index 531d7faf2b3..4c1cd2c5608 100644 --- a/searchlib/src/vespa/searchlib/tensor/distance_function.h +++ b/searchlib/src/vespa/searchlib/tensor/distance_function.h @@ -16,18 +16,18 @@ namespace search::tensor { * The actual implementation must know which type the vectors are. */ class DistanceFunction { -protected: - vespalib::eval::CellType expect_cell_type; +private: + vespalib::eval::CellType _expect_cell_type; public: using UP = std::unique_ptr<DistanceFunction>; - DistanceFunction(vespalib::eval::CellType expected) : expect_cell_type(expected) {} + DistanceFunction(vespalib::eval::CellType expected) : _expect_cell_type(expected) {} virtual ~DistanceFunction() {} // input (query) vectors must be converted to this cell type: vespalib::eval::CellType expected_cell_type() const { - return expect_cell_type; + return _expect_cell_type; } // calculate internal distance (comparable) diff --git a/searchlib/src/vespa/searchlib/tensor/euclidean_distance.h b/searchlib/src/vespa/searchlib/tensor/euclidean_distance.h index 380c6b2add2..0669476c7aa 100644 --- a/searchlib/src/vespa/searchlib/tensor/euclidean_distance.h +++ b/searchlib/src/vespa/searchlib/tensor/euclidean_distance.h @@ -40,7 +40,9 @@ public: SquaredEuclideanDistanceHW() : SquaredEuclideanDistance(vespalib::eval::get_cell_type<FloatType>()), _computer(vespalib::hwaccelrated::IAccelrated::getAccelerator()) - {} + { + assert(expected_cell_type() == vespalib::eval::get_cell_type<FloatType>()); + } double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { constexpr vespalib::eval::CellType expected = vespalib::eval::get_cell_type<FloatType>(); assert(lhs.type == expected && rhs.type == expected); diff --git a/searchlib/src/vespa/searchlib/tensor/inner_product_distance.h b/searchlib/src/vespa/searchlib/tensor/inner_product_distance.h index a6ecb4eb7bb..981dedea141 100644 --- a/searchlib/src/vespa/searchlib/tensor/inner_product_distance.h +++ b/searchlib/src/vespa/searchlib/tensor/inner_product_distance.h @@ -44,7 +44,9 @@ public: InnerProductDistanceHW() : InnerProductDistance(vespalib::eval::get_cell_type<FloatType>()), _computer(vespalib::hwaccelrated::IAccelrated::getAccelerator()) - {} + { + assert(expected_cell_type() == vespalib::eval::get_cell_type<FloatType>()); + } double calc(const vespalib::eval::TypedCells& lhs, const vespalib::eval::TypedCells& rhs) const override { constexpr vespalib::eval::CellType expected = vespalib::eval::get_cell_type<FloatType>(); assert(lhs.type == expected && rhs.type == expected); |