Skip to content
heliaRT
API reference
HELIA HUB

RecordingMicroAllocator

Allocation accounting for memory diagnostics.

Machine-readable model

class

Utility subclass of MicroAllocator that records all allocations inside the arena.

tensorflow/lite/micro/recording_micro_allocator.h:60

class RecordingMicroAllocator : public tflite::MicroAllocator

Utility subclass of MicroAllocator that records all allocations inside the arena. A summary of allocations can be logged through the ErrorReporter by invoking LogAllocations(). This special allocator requires an instance of RecordingSingleArenaBufferAllocator to capture allocations in the head and tail. Arena allocation recording can be retrieved by type through the GetRecordedAllocation() function. This class should only be used for auditing memory usage or integration testing.

method

tensorflow/lite/micro/recording_micro_allocator.h:62

static RecordingMicroAllocator * tflite::RecordingMicroAllocator::Create(uint8_t *tensor_arena, size_t arena_size)
Parameters of Create
NameTypeDefaultDescription
tensor_arenauint8_t *Required
arena_sizesize_tRequired
method

Returns the recorded allocations information for a given allocation type.

tensorflow/lite/micro/recording_micro_allocator.h:69

RecordedAllocation tflite::RecordingMicroAllocator::GetRecordedAllocation(RecordedAllocationType allocation_type) const

Returns the recorded allocations information for a given allocation type.

Parameters of GetRecordedAllocation
NameTypeDefaultDescription
allocation_typeRecordedAllocationTypeRequired
method

Logs out through the ErrorReporter all allocation recordings by type defined in RecordedAllocationType.

tensorflow/lite/micro/recording_micro_allocator.h:76

void tflite::RecordingMicroAllocator::PrintAllocations() const

Logs out through the ErrorReporter all allocation recordings by type defined in RecordedAllocationType.

method

Allocates persistent buffer which has the same life time as the allocator.

tensorflow/lite/micro/recording_micro_allocator.h:78

void * tflite::RecordingMicroAllocator::AllocatePersistentBuffer(size_t bytes)

Allocates persistent buffer which has the same life time as the allocator. The memory is immediately available and is allocated from the tail of the arena.

Parameters of AllocatePersistentBuffer
NameTypeDefaultDescription
bytessize_tRequired
method

Allocates an array in the arena to hold pointers to the node and registration pointers required to represent the inference graph of the model.

tensorflow/lite/micro/recording_micro_allocator.h:81

TfLiteStatus tflite::RecordingMicroAllocator::AllocateNodeAndRegistrations(
const Model *model,
SubgraphAllocations *subgraph_allocations
)

Allocates an array in the arena to hold pointers to the node and registration pointers required to represent the inference graph of the model.

Parameters of AllocateNodeAndRegistrations
NameTypeDefaultDescription
modelconst Model *Required
subgraph_allocationsSubgraphAllocations *Required
method

Allocates the list of persistent TfLiteEvalTensors that are used for the "eval" phase of model inference.

tensorflow/lite/micro/recording_micro_allocator.h:83

TfLiteStatus tflite::RecordingMicroAllocator::AllocateTfLiteEvalTensors(
const Model *model,
SubgraphAllocations *subgraph_allocations
)

Allocates the list of persistent TfLiteEvalTensors that are used for the “eval” phase of model inference. These structs will be the source of truth for all tensor buffers.

Parameters of AllocateTfLiteEvalTensors
NameTypeDefaultDescription
modelconst Model *Required
subgraph_allocationsSubgraphAllocations *Required
method

Allocates persistent tensor buffers for variable tensors in the subgraph.

tensorflow/lite/micro/recording_micro_allocator.h:85

TfLiteStatus tflite::RecordingMicroAllocator::AllocateVariables(
const SubGraph *subgraph,
TfLiteEvalTensor *eval_tensors,
const int32_t *offline_planner_offsets
)

Allocates persistent tensor buffers for variable tensors in the subgraph. Online and offline variable tensors are handled differently hence the offline_planner_offsets parameter is needed.

Parameters of AllocateVariables
NameTypeDefaultDescription
subgraphconst SubGraph *Required
eval_tensorsTfLiteEvalTensor *Required
offline_planner_offsetsconst int32_t *Required
method

TODO(b/162311891): Once all kernels have been updated to the new API drop this function since all allocations for quantized data will take place in the temp se…

tensorflow/lite/micro/recording_micro_allocator.h:95

TfLiteStatus tflite::RecordingMicroAllocator::PopulateTfLiteTensorFromFlatbuffer(
const Model *model,
TfLiteTensor *tensor,
int tensor_index,
int subgraph_index,
bool allocate_temp
)

TODO(b/162311891): Once all kernels have been updated to the new API drop this function since all allocations for quantized data will take place in the temp section.

Parameters of PopulateTfLiteTensorFromFlatbuffer
NameTypeDefaultDescription
modelconst Model *Required
tensorTfLiteTensor *Required
tensor_indexintRequired
subgraph_indexintRequired
allocate_tempboolRequired