aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/tensor/tensor_buffer_type_mapper.h
blob: 6af318e63c7b0609e7857762dcedd6ce725f46d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/datastore/array_store_type_mapper.h>

namespace search::tensor {

class LargeSubspacesBufferType;
class SmallSubspacesBufferType;
class TensorBufferOperations;

/*
 * This class provides mapping between type ids and array sizes needed for
 * storing a tensor.
 */
class TensorBufferTypeMapper : public vespalib::datastore::ArrayStoreTypeMapper
{
    TensorBufferOperations* _ops;
public:
    using SmallBufferType = SmallSubspacesBufferType;
    using LargeBufferType = LargeSubspacesBufferType;

    TensorBufferTypeMapper();
    TensorBufferTypeMapper(uint32_t max_small_subspaces_type_id, double grow_factor, size_t max_buffer_size, TensorBufferOperations* ops);
    ~TensorBufferTypeMapper();

    TensorBufferOperations& get_tensor_buffer_operations() const noexcept { return *_ops; }
    size_t get_entry_size(uint32_t type_id) const { return get_array_size(type_id); }
};

}