Skip to content

Commit f31e492

Browse files
committed
Update base for Update on "[Executorch] Use temp allocator for allocating scratch memory"
This allows us to leverage temp memory allocator and if that allocator is caching allocator it reduces the allocaiton overhead. Differential Revision: [D85532076](https://our.internmc.facebook.com/intern/diff/D85532076/) [ghstack-poisoned]
1 parent 10b835a commit f31e492

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

extension/memory_allocator/malloc_memory_allocator.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ class MallocMemoryAllocator : public executorch::runtime::MemoryAllocator {
5252
return nullptr;
5353
}
5454

55-
size_t adjusted_size = executorch::extension::utils::get_aligned_size(size, alignment);
56-
if (adjusted_size == 0) {
57-
return nullptr;
58-
}
59-
size = adjusted_size;
55+
size = executorch::extension::utils::get_aligned_size(size, alignment);
6056
void* mem_ptr = std::malloc(size);
6157
if (!mem_ptr) {
6258
ET_LOG(Error, "Malloc failed to allocate %zu bytes", size);

extension/memory_allocator/targets.bzl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ def define_common_targets():
99

1010
runtime.cxx_library(
1111
name = "malloc_memory_allocator",
12-
headers = [
13-
"memory_allocator_utils.h",
14-
],
1512
exported_headers = [
1613
"malloc_memory_allocator.h",
14+
"memory_allocator_utils.h",
1715
],
1816
exported_deps = [
1917
"//executorch/runtime/core:memory_allocator",
@@ -26,14 +24,12 @@ def define_common_targets():
2624

2725
runtime.cxx_library(
2826
name = "cpu_caching_allocator",
29-
headers = [
30-
"memory_allocator_utils.h",
31-
],
3227
srcs = [
3328
"cpu_caching_malloc_allocator.cpp",
3429
],
3530
exported_headers = [
3631
"cpu_caching_malloc_allocator.h",
32+
"memory_allocator_utils.h",
3733
],
3834
exported_deps = [
3935
"//executorch/runtime/core:memory_allocator",

0 commit comments

Comments
 (0)