diff options
author | Geir Storli <geirst@yahooinc.com> | 2022-10-28 17:32:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-28 17:32:42 +0200 |
commit | 1818d905c05d8072d557782138697cb5b0f5cb63 (patch) | |
tree | 926020eb5c53cda5f0a81b9924b27f654bf8736e /searchlib | |
parent | 6e93532536910b6666ed4240fb16b2a0364c60a7 (diff) | |
parent | 52b4eb47d18b35f2bdc3974ef4efe67678c6e2a9 (diff) |
Merge pull request #24644 from vespa-engine/toregge/move-tensor-attribute-constants-to-separate-header-file
Move tensor attribute constants to separate header file.
Diffstat (limited to 'searchlib')
4 files changed, 25 insertions, 12 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp index 56b9473b6e6..e2b516154fd 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp @@ -5,6 +5,7 @@ #include "nearest_neighbor_index.h" #include "nearest_neighbor_index_loader.h" #include "nearest_neighbor_index_saver.h" +#include "tensor_attribute_constants.h" #include <vespa/eval/eval/value.h> #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/searchcommon/attribute/config.h> @@ -31,15 +32,12 @@ namespace search::tensor { namespace { -constexpr uint32_t DENSE_TENSOR_ATTRIBUTE_VERSION = 1; constexpr uint32_t LOAD_COMMIT_INTERVAL = 256; const vespalib::string tensorTypeTag("tensortype"); class BlobSequenceReader : public ReaderBase { private: - static constexpr uint8_t tensorIsNotPresent = 0; - static constexpr uint8_t tensorIsPresent = 1; bool _use_index_file; FileWithHeader _index_file; diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp index 5c98da91034..5a47addd4ab 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute_saver.cpp @@ -3,6 +3,7 @@ #include "dense_tensor_attribute_saver.h" #include "dense_tensor_store.h" #include "nearest_neighbor_index_saver.h" +#include "tensor_attribute_constants.h" #include <vespa/searchlib/util/bufferwriter.h> #include <vespa/searchlib/attribute/iattributesavetarget.h> @@ -10,13 +11,6 @@ using vespalib::GenerationHandler; namespace search::tensor { -namespace { - -constexpr uint8_t tensorIsNotPresent = 0; -constexpr uint8_t tensorIsPresent = 1; - -} - DenseTensorAttributeSaver:: DenseTensorAttributeSaver(GenerationHandler::Guard &&guard, const attribute::AttributeHeader &header, diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp index f29751cdabe..84944ea685e 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp @@ -2,6 +2,7 @@ #include "tensor_attribute.h" #include "blob_sequence_reader.h" +#include "tensor_attribute_constants.h" #include "tensor_store_saver.h" #include <vespa/document/base/exceptions.h> #include <vespa/document/datatype/tensor_data_type.h> @@ -31,8 +32,6 @@ namespace search::tensor { namespace { -constexpr uint32_t TENSOR_ATTRIBUTE_VERSION = 0; - Value::UP createEmptyTensor(const ValueType &type) { diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute_constants.h b/searchlib/src/vespa/searchlib/tensor/tensor_attribute_constants.h new file mode 100644 index 00000000000..ab25f4b71a1 --- /dev/null +++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute_constants.h @@ -0,0 +1,22 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <cstdint> + +namespace search::tensor { + +/* + * Attribute version determines format of saved attributes. + */ +inline constexpr uint32_t TENSOR_ATTRIBUTE_VERSION = 0; +inline constexpr uint32_t DENSE_TENSOR_ATTRIBUTE_VERSION = 1; + +/* + * Values used to determine if a tensor is present or not for dense tensor attributes + * (cf. DENSE_TENSOR_ATTRIBUTE_VERSION) that otherwise has fixed size for a saved tensor. + */ +inline constexpr uint8_t tensorIsNotPresent = 0; +inline constexpr uint8_t tensorIsPresent = 1; + +} |