/home/runner/work/LabNeura/LabNeura/include/labneura/backends/common/tensor_storage.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include "labneura/tensor.h" |
4 | | #include "labneura/visibility.h" |
5 | | |
6 | | #include <cstddef> |
7 | | #include <memory> |
8 | | |
9 | | namespace labneura { |
10 | | |
11 | | class LABNEURA_API TensorStorage final { |
12 | | public: |
13 | | using Deleter = void (*)(void*); |
14 | | |
15 | | TensorStorage(const TensorStorage&) = delete; |
16 | | TensorStorage& operator=(const TensorStorage&) = delete; |
17 | | ~TensorStorage(); |
18 | | |
19 | | static std::shared_ptr<TensorStorage> allocate( |
20 | | std::size_t logical_size, std::size_t allocation_capacity, |
21 | | QuantizationMode dtype, std::size_t alignment); |
22 | | static std::shared_ptr<TensorStorage> adopt( |
23 | | void* data, std::size_t logical_size, |
24 | | std::size_t allocation_capacity, QuantizationMode dtype, |
25 | | std::size_t alignment, Deleter deleter); |
26 | | |
27 | 4.44k | void* data() noexcept { return data_; } |
28 | 0 | const void* data() const noexcept { return data_; } |
29 | | |
30 | | const std::size_t logical_size; |
31 | | const std::size_t allocation_capacity; |
32 | | const QuantizationMode dtype; |
33 | | const std::size_t alignment; |
34 | | |
35 | | private: |
36 | | TensorStorage(void* data, std::size_t logical_size, |
37 | | std::size_t allocation_capacity, QuantizationMode dtype, |
38 | | std::size_t alignment, Deleter deleter); |
39 | | |
40 | | void* data_; |
41 | | Deleter deleter_; |
42 | | }; |
43 | | |
44 | | } // namespace labneura |