31 _start_block->size =
memSize -
sizeof(Block);
32 _start_block->is_free =
true;
33 _start_block->self = _start_block;
35 _size = _start_block->size;
40 addToBlocks(_start_block,
p);
46 const int32_t num_elements = tensor.shape().num_elements();
47 auto size = num_elements * element_size;
53 while (l < 32 && !_free_blocks[l])
58 throw std::runtime_error{
"Memory limit exceeded"};
62 tmp = _free_blocks[l];
63 removeFromBlocks(
tmp, l);
65 while ((
tmp->size +
sizeof(Block)) / 2 >=
size +
sizeof(Block))
76 tensor.set_data_buffer(
data);
81 auto data = tensor.data<
void>();
87 addToBlocks(
tmp, lowerLog2(
tmp->size +
sizeof(Block)));
90 if (
tmp->size == _size)
96 tensor.set_data_buffer(
nullptr);
void allocate_memory(luci_interpreter::Tensor &tensor) final
void release_memory(luci_interpreter::Tensor &tensor) final
BuddyMemoryManager(uint8_t *memory_start, int32_t memSize)
const T * data(const std::vector< T, Alloc > &v)
size_t getDataTypeSize(DataType data_type)
T must_cast(loco::Node *node)