From 22c61675e86cbd82930fc393791e8c9a1a51cd33 Mon Sep 17 00:00:00 2001 From: rstehle Date: Wed, 22 Jul 2026 08:30:39 -0700 Subject: [PATCH] Resolve Operator fallback to method allocator if temp alloc fails (#20981) (#20981) Summary: Currently, the resolve_operator step during method_init will fall back to method allocator if temp allocator is zero or not present. This change adds logic to fallback to method allocator if temp allocator is present, but insufficient in size for the tensor meta. Reviewed By: rascani Differential Revision: D109855815 Pulled By: rstehle --- runtime/executor/method.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/executor/method.cpp b/runtime/executor/method.cpp index 8eb48480463..8c559c8887d 100644 --- a/runtime/executor/method.cpp +++ b/runtime/executor/method.cpp @@ -761,7 +761,10 @@ Error Method::resolve_operator( // However, it does not have to be provided, so if it // is not provided (or an empty one is provided), we // fall back to the method allocator. - if (allocator == nullptr || allocator->size() == 0) { + if (allocator == nullptr || allocator->size() == 0 || + allocator->size() < (sizeof(TensorMeta) * n_args) + + (sizeof(executorch::aten::DimOrderType) * kTensorDimensionLimit * + n_args)) { allocator = memory_manager_->method_allocator(); } TensorMeta* meta = allocator->allocateList(n_args);