Skip to content

Commit

Permalink
Merge pull request #24292 from vespa-engine/toregge/use-array-store-a…
Browse files Browse the repository at this point in the history
…llocate-in-tensor-buffer-store-store-tensor

Use ArrayStore::allocate in TensorBufferStore::store_tensor.
  • Loading branch information
geirst authored Oct 3, 2022
2 parents 11b8f06 + ff3abaf commit 1fafdfd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ TensorBufferStore::TensorBufferStore(const ValueType& tensor_type, std::shared_p
_array_store(ArrayStoreType::optimizedConfigForHugePage(max_small_subspaces_type_id,
TensorBufferTypeMapper(max_small_subspaces_type_id, &_ops),
MemoryAllocator::HUGEPAGE_SIZE, 4_Ki, 8_Ki, ALLOC_GROW_FACTOR),
std::move(allocator), TensorBufferTypeMapper(max_small_subspaces_type_id, &_ops)),
_add_buffer()
std::move(allocator), TensorBufferTypeMapper(max_small_subspaces_type_id, &_ops))
{
}

Expand Down Expand Up @@ -60,9 +59,10 @@ TensorBufferStore::store_tensor(const Value &tensor)
{
uint32_t num_subspaces = tensor.index().size();
auto array_size = _ops.get_array_size(num_subspaces);
_add_buffer.resize(array_size);
_ops.store_tensor(_add_buffer, tensor);
return _array_store.add(_add_buffer);
auto ref = _array_store.allocate(array_size);
auto buf = _array_store.get_writable(ref);
_ops.store_tensor(buf, tensor);
return ref;
}

EntryRef
Expand Down
1 change: 0 additions & 1 deletion searchlib/src/vespa/searchlib/tensor/tensor_buffer_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class TensorBufferStore : public TensorStore
vespalib::eval::ValueType _tensor_type;
TensorBufferOperations _ops;
ArrayStoreType _array_store;
std::vector<char> _add_buffer;
public:
TensorBufferStore(const vespalib::eval::ValueType& tensor_type, std::shared_ptr<vespalib::alloc::MemoryAllocator> allocator, uint32_t max_small_subspaces_type_id);
~TensorBufferStore();
Expand Down

0 comments on commit 1fafdfd

Please sign in to comment.