ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci_interpreter::TestMemoryManager Class Reference

#include <TestMemoryManager.h>

Collaboration diagram for luci_interpreter::TestMemoryManager:

Public Member Functions

void allocate_memory (luci_interpreter::Tensor &tensor) final
 
void release_memory (luci_interpreter::Tensor &tensor) final
 
 ~TestMemoryManager () override
 
- Public Member Functions inherited from luci_interpreter::IMemoryManager
virtual ~IMemoryManager ()=default
 

Detailed Description

Definition at line 27 of file TestMemoryManager.h.

Constructor & Destructor Documentation

◆ ~TestMemoryManager()

luci_interpreter::TestMemoryManager::~TestMemoryManager ( )
inlineoverride

Definition at line 33 of file TestMemoryManager.h.

34 {
35 for (auto allocation : allocations)
36 {
37 delete[] allocation;
38 }
39 }

Member Function Documentation

◆ allocate_memory()

void luci_interpreter::TestMemoryManager::allocate_memory ( luci_interpreter::Tensor tensor)
finalvirtual

Implements luci_interpreter::IMemoryManager.

Definition at line 22 of file TestMemoryManager.cpp.

23{
24 if (!tensor.is_allocatable())
25 {
26 return;
27 }
28 if (tensor.is_data_allocated())
29 {
30 release_memory(tensor);
31 }
32 const auto element_size = getDataTypeSize(tensor.element_type());
33 const auto num_elements = tensor.shape().num_elements();
34
35 auto *data = new uint8_t[num_elements * element_size];
36 allocations.push_back(data);
37 tensor.set_data_buffer(data);
38}
void release_memory(luci_interpreter::Tensor &tensor) final
const T * data(const std::vector< T, Alloc > &v)
size_t getDataTypeSize(DataType data_type)
Definition DataType.h:33
uint32_t num_elements(const Shape &shape)
The number of elements of a feature map of a given shape.
Definition Shape.h:59

References flatbuffers::data(), luci_interpreter::getDataTypeSize(), and release_memory().

◆ release_memory()

void luci_interpreter::TestMemoryManager::release_memory ( luci_interpreter::Tensor tensor)
finalvirtual

Implements luci_interpreter::IMemoryManager.

Definition at line 40 of file TestMemoryManager.cpp.

41{
42 tensor.set_data_buffer(nullptr);
43}

Referenced by allocate_memory().


The documentation for this class was generated from the following files: