Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions examples/arm/executor_runner/arm_executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,13 +763,7 @@ void log_mem_status(const RunnerContext& ctx) {
ET_LOG(Info, "method_allocator_executor: %zu bytes", executor_memsize);
}
if (ctx.temp_allocator->size() > 0) {
ET_LOG(
Info,
"peak_temp_allocator: %zu / %zu free: %zu ( used: %zu %% ) ",
ctx.temp_allocator->peak_used(),
ctx.temp_allocator->size(),
ctx.temp_allocator->free_size(),
100 * ctx.temp_allocator->peak_used() / ctx.temp_allocator->size());
ET_LOG(Info, "temp_allocator: %zu", ctx.temp_allocator->size());
}
}

Expand Down Expand Up @@ -927,15 +921,20 @@ void verify_result(RunnerContext& ctx, const void* model_pte) {
void run_model(RunnerContext& ctx, const void* model_pte) {
Error status;
ET_LOG(Info, "Starting running %d inferences...", num_inferences);

int n = 0;
StartMeasurements();
for (n = 0; n < num_inferences; n++) {
ET_LOG(Debug, "Running inference number %d", n);
// Run the model.
status = ctx.method.value()->execute();
if (status != Error::Ok) {
break;
}
// Reset the temporary allocator holding the scratch buffer between
// inferences. We want to reuse the temp_allocator between inferences of the
// same Ethos-U custom delegate, not allocate memory with every new
// inference.
ctx.temp_allocator.reset(temp_allocation_pool_size, temp_allocation_pool);
}
StopMeasurements(n);

Expand Down
8 changes: 1 addition & 7 deletions examples/arm/executor_runner/arm_memory_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "arm_memory_allocator.h"

ArmMemoryAllocator::ArmMemoryAllocator(uint32_t size, uint8_t* base_address)
: MemoryAllocator(size, base_address), used_(0), peak_used_(0) {}
: MemoryAllocator(size, base_address), used_(0) {}

void* ArmMemoryAllocator::allocate(size_t size, size_t alignment) {
void* ret = executorch::runtime::MemoryAllocator::allocate(size, alignment);
Expand All @@ -22,8 +22,6 @@ void* ArmMemoryAllocator::allocate(size_t size, size_t alignment) {
} else {
used_ = (used_ | (alignment - 1)) + 1 + size;
}
if (used_ > peak_used_)
peak_used_ = used_;
}
return ret;
}
Expand All @@ -32,10 +30,6 @@ size_t ArmMemoryAllocator::used_size() const {
return used_;
}

size_t ArmMemoryAllocator::peak_used() const {
return peak_used_;
}

size_t ArmMemoryAllocator::free_size() const {
return executorch::runtime::MemoryAllocator::size() - used_;
}
Expand Down
5 changes: 0 additions & 5 deletions examples/arm/executor_runner/arm_memory_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ class ArmMemoryAllocator : public executorch::runtime::MemoryAllocator {
// Returns the used size of the allocator's memory buffer.
size_t used_size() const;

// Returns the peak memory usage of the allocator's memory buffer
// Peak usage is useful when doing multiple allocations & resets
size_t peak_used() const;

// Returns the free size of the allocator's memory buffer.
size_t free_size() const;
void reset();

private:
size_t used_;
size_t peak_used_;
};
Loading