blob: ad2116a429c017d06ef6b6084d2d4b3f6e8efaa2 (
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
33
34
35
36
37
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <cstddef>
#include <cstdint>
#include <vector>
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
{
std::vector<size_t> _array_sizes;
TensorBufferOperations* _ops;
public:
using SmallBufferType = SmallSubspacesBufferType;
using LargeBufferType = LargeSubspacesBufferType;
TensorBufferTypeMapper();
TensorBufferTypeMapper(uint32_t max_small_subspaces_type_id, double grow_factor, TensorBufferOperations* ops);
~TensorBufferTypeMapper();
uint32_t get_type_id(size_t array_size) const;
size_t get_array_size(uint32_t type_id) const;
TensorBufferOperations& get_tensor_buffer_operations() const noexcept { return *_ops; }
uint32_t get_max_small_array_type_id(uint32_t max_small_array_type_id) const noexcept;
};
}
|