Skip to content

Commit d2ba238

Browse files
Mergen Nachinfacebook-github-bot
authored andcommitted
Revert D62874650: Arm backend: Track target memory usage
Differential Revision: D62874650 Original commit changeset: 9b737d973466 Original Phabricator Diff: D62874650 fbshipit-source-id: 4a690effe190e77a64a0956884f49575134394d3
1 parent e425dbb commit d2ba238

File tree

2 files changed

+3
-43
lines changed

2 files changed

+3
-43
lines changed

examples/arm/executor_runner/arm_executor_runner.cpp

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// needs to be large enough to take an entire model. On the FVP,
2929
// network_model_sec is linked to the DDR, which is large (256MB on
3030
// Corstone-300).
31-
const size_t input_allocation_pool_size = 60 * 1024 * 1024;
31+
const size_t input_allocation_pool_size = 100 * 1024 * 1024;
3232
unsigned char __attribute__((
3333
section("network_model_sec"),
3434
aligned(16))) input_allocation_pool[input_allocation_pool_size];
@@ -63,7 +63,7 @@ using executorch::runtime::Span;
6363
using executorch::runtime::Tag;
6464
using executorch::runtime::TensorInfo;
6565

66-
#define METHOD_ALLOCATOR_POOL_SIZE (60 * 1024 * 1024)
66+
#define METHOD_ALLOCATOR_POOL_SIZE (70 * 1024 * 1024)
6767
unsigned char __attribute__((
6868
section("network_model_sec"),
6969
aligned(16))) method_allocation_pool[METHOD_ALLOCATOR_POOL_SIZE];
@@ -326,8 +326,6 @@ int main(int argc, const char* argv[]) {
326326
std::vector<Span<uint8_t>> planned_spans; // Passed to the allocator
327327
size_t num_memory_planned_buffers = method_meta->num_memory_planned_buffers();
328328

329-
size_t planned_buffer_membase = method_allocator.used_size();
330-
331329
for (size_t id = 0; id < num_memory_planned_buffers; ++id) {
332330
size_t buffer_size =
333331
static_cast<size_t>(method_meta->memory_planned_buffer_size(id).get());
@@ -339,8 +337,6 @@ int main(int argc, const char* argv[]) {
339337
planned_buffers.push_back(buffer);
340338
planned_spans.push_back({planned_buffers.back(), buffer_size});
341339
}
342-
size_t planned_buffer_memsize =
343-
method_allocator.used_size() - planned_buffer_membase;
344340

345341
HierarchicalAllocator planned_memory(
346342
{planned_spans.data(), planned_spans.size()});
@@ -351,7 +347,6 @@ int main(int argc, const char* argv[]) {
351347
MemoryManager memory_manager(
352348
&method_allocator, &planned_memory, &temp_allocator);
353349

354-
size_t method_loaded_membase = method_allocator.used_size();
355350
Result<Method> method = program->load_method(method_name, &memory_manager);
356351
if (!method.ok()) {
357352
ET_LOG(
@@ -360,12 +355,10 @@ int main(int argc, const char* argv[]) {
360355
method_name,
361356
method.error());
362357
}
363-
size_t method_loaded_memsize =
364-
method_allocator.used_size() - method_loaded_membase;
365358
ET_LOG(Info, "Method loaded.");
366359

367360
ET_LOG(Info, "Preparing inputs...");
368-
size_t input_membase = method_allocator.used_size();
361+
369362
auto inputs =
370363
::prepare_input_tensors(*method, method_allocator, input_buffers);
371364

@@ -376,15 +369,12 @@ int main(int argc, const char* argv[]) {
376369
method_name,
377370
inputs.error());
378371
}
379-
size_t input_memsize = method_allocator.used_size() - input_membase;
380372
ET_LOG(Info, "Input prepared.");
381373

382374
ET_LOG(Info, "Starting the model execution...");
383-
size_t executor_membase = method_allocator.used_size();
384375
StartMeasurements();
385376
Error status = method->execute();
386377
StopMeasurements();
387-
size_t executor_memsize = method_allocator.used_size() - executor_membase;
388378

389379
if (status != Error::Ok) {
390380
ET_LOG(
@@ -435,25 +425,6 @@ int main(int argc, const char* argv[]) {
435425
}
436426
out:
437427
ET_LOG(Info, "Program complete, exiting.");
438-
if (method_allocator.size() != 0) {
439-
size_t method_allocator_used = method_allocator.used_size();
440-
ET_LOG(
441-
Info,
442-
"Method allocator area ( method_allocator_planned: %zu method_allocator_loaded: %zu method_allocator_input: %zu method_allocator_executor: %zu ) total: %zu",
443-
planned_buffer_memsize,
444-
method_loaded_memsize,
445-
input_memsize,
446-
executor_memsize,
447-
method_allocator_used);
448-
ET_LOG(
449-
Info,
450-
"Method allocator area method_allocator_used: %d / method_allocator_size: %d method_allocator_free: %d ( used: %d %% ) ",
451-
method_allocator_used,
452-
method_allocator.size(),
453-
method_allocator.free_size(),
454-
100 * method_allocator_used / method_allocator.size());
455-
}
456-
457428
#ifdef SEMIHOSTING
458429
_exit(0);
459430
#endif

runtime/core/memory_allocator.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
22
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
* All rights reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates.
54
*
65
* This source code is licensed under the BSD-style license found in the
76
* LICENSE file in the root directory of this source tree.
@@ -151,16 +150,6 @@ class MemoryAllocator {
151150
return size_;
152151
}
153152

154-
// Returns the used size of the allocator's memory buffer.
155-
virtual uint32_t used_size() const {
156-
return cur_ - begin_;
157-
}
158-
159-
// Returns the free size of the allocator's memory buffer.
160-
virtual uint32_t free_size() const {
161-
return end_ - cur_;
162-
}
163-
164153
// Resets the current pointer to the base address. It does nothing to
165154
// the contents.
166155
virtual void reset() {

0 commit comments

Comments
 (0)