Skip to content

Commit 0b40181

Browse files
JakeStevensfacebook-github-bot
authored andcommitted
Use temp allocator for kernel registry (#13012)
Summary: When indexing to the registry to get the op, memory is allocated from the method allocator to instantiate some TensorMeta and included objects. This memory is only used for that purpose and is not needed for the entire lifetime of the Method. Thus, we can instead use temp allocator which can later be reset and free up memory as needed. Differential Revision: D79285675
1 parent bdf658b commit 0b40181

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

runtime/executor/method.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ Error Method::resolve_operator(
670670
size_t kernel_index,
671671
InstructionArgs args,
672672
size_t n_args) {
673-
// TODO(T153505381, T153506819) Investigate optimizing this function for both
673+
// TODO(T153506819) Investigate optimizing this function for both
674674
// space and time.
675675

676676
// resolve name
@@ -691,8 +691,8 @@ Error Method::resolve_operator(
691691
}
692692

693693
// resolve tensor meta
694-
auto method_allocator = memory_manager_->method_allocator();
695-
TensorMeta* meta = method_allocator->allocateList<TensorMeta>(n_args);
694+
auto temp_allocator = memory_manager_->temp_allocator();
695+
TensorMeta* meta = temp_allocator->allocateList<TensorMeta>(n_args);
696696
if (meta == nullptr) {
697697
return Error::MemoryAllocationFailed;
698698
}
@@ -705,7 +705,7 @@ Error Method::resolve_operator(
705705
auto tensor = eval->toTensor();
706706
meta[count].dtype_ = tensor.scalar_type();
707707
executorch::aten::DimOrderType* dim_order_ptr =
708-
method_allocator->allocateList<executorch::aten::DimOrderType>(
708+
temp_allocator->allocateList<executorch::aten::DimOrderType>(
709709
tensor.dim());
710710
if (dim_order_ptr == nullptr) {
711711
return Error::MemoryAllocationFailed;

0 commit comments

Comments
 (0)