diff --git a/examples/arm/executor_runner/arm_executor_runner.cpp b/examples/arm/executor_runner/arm_executor_runner.cpp index ea54c9ca605..d56710e27ad 100644 --- a/examples/arm/executor_runner/arm_executor_runner.cpp +++ b/examples/arm/executor_runner/arm_executor_runner.cpp @@ -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()); } } @@ -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); diff --git a/examples/arm/executor_runner/arm_memory_allocator.cpp b/examples/arm/executor_runner/arm_memory_allocator.cpp index e22439a239d..6b627625ae1 100644 --- a/examples/arm/executor_runner/arm_memory_allocator.cpp +++ b/examples/arm/executor_runner/arm_memory_allocator.cpp @@ -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); @@ -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; } @@ -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_; } diff --git a/examples/arm/executor_runner/arm_memory_allocator.h b/examples/arm/executor_runner/arm_memory_allocator.h index f7e8939c655..1d7bbdecb4c 100644 --- a/examples/arm/executor_runner/arm_memory_allocator.h +++ b/examples/arm/executor_runner/arm_memory_allocator.h @@ -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_; };