diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-09-30 12:01:36 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-09-30 12:01:36 +0200 |
commit | 7dc4ed00c0a23248e2c5e48333786b0c2341d0fa (patch) | |
tree | 1aba291d6839f23ab7f8324e93a01643b8a9f6a9 /searchlib | |
parent | 1668220ebc309ac482279d5823dcbb4928b7c3e4 (diff) |
Extend class comment with short description of memory layout for stored
tensor.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.cpp | 10 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.h | 11 |
2 files changed, 16 insertions, 5 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.cpp index ba8b550a779..807975c392a 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.cpp +++ b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.cpp @@ -35,23 +35,23 @@ adjust_min_alignment(size_t min_alignment) return std::max(std::max(sizeof(uint32_t), sizeof(string_id)), min_alignment); } -struct MyFastValueView final : Value { +struct FastValueView final : Value { const ValueType& _type; StringIdVector _labels; FastValueIndex _index; TypedCells _cells; - MyFastValueView(const ValueType& type, ConstArrayRef<string_id> labels, TypedCells cells, size_t num_mapped_dimensions, size_t num_subspaces); + FastValueView(const ValueType& type, ConstArrayRef<string_id> labels, TypedCells cells, size_t num_mapped_dimensions, size_t num_subspaces); const ValueType& type() const override { return _type; } const Value::Index& index() const override { return _index; } TypedCells cells() const override { return _cells; } MemoryUsage get_memory_usage() const override { - MemoryUsage usage = self_memory_usage<MyFastValueView>(); + MemoryUsage usage = self_memory_usage<FastValueView>(); usage.merge(_index.map.estimate_extra_memory_usage()); return usage; } }; -MyFastValueView::MyFastValueView(const ValueType& type, ConstArrayRef<string_id> labels, TypedCells cells, size_t num_mapped_dimensions, size_t num_subspaces) +FastValueView::FastValueView(const ValueType& type, ConstArrayRef<string_id> labels, TypedCells cells, size_t num_mapped_dimensions, size_t num_subspaces) : Value(), _type(type), _labels(labels.begin(), labels.end()), @@ -144,7 +144,7 @@ TensorBufferOperations::make_fast_view(ConstArrayRef<char> buf, const vespalib:: auto cells_start_offset = get_cells_offset(num_subspaces, alignment); TypedCells cells(buf.data() + cells_start_offset, _cell_type, cells_size); assert(cells_start_offset + cells_mem_size <= buf.size()); - return std::make_unique<MyFastValueView>(tensor_type, labels, cells, _num_mapped_dimensions, num_subspaces); + return std::make_unique<FastValueView>(tensor_type, labels, cells, _num_mapped_dimensions, num_subspaces); } void diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.h b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.h index 72b00e79426..ab3777d7526 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.h +++ b/searchlib/src/vespa/searchlib/tensor/tensor_buffer_operations.h @@ -23,6 +23,17 @@ namespace search::tensor { /* * Class used to store a tensor in a buffer and make tensor views based on * buffer content. + * + * Layout of buffer is: + * + * num_subspaces - number of subspaces + * labels[num_subspaces * _num_mapped_dimensions] - array of labels for sparse dimensions + * padding - to align start of cells + * cells[num_subspaces * _dense_subspaces_size] - array of tensor cell values + * padding - to align start of next buffer + * + * Alignment is dynamic, based on cell type, memory used by tensor cell values and + * alignment required for reading num_subspaces and labels array. */ class TensorBufferOperations { |