Skip to content

Commit b36c074

Browse files
rstehlefacebook-github-bot
authored andcommitted
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
1 parent 8a19761 commit b36c074

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

runtime/executor/method.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,10 @@ Error Method::resolve_operator(
761761
// However, it does not have to be provided, so if it
762762
// is not provided (or an empty one is provided), we
763763
// fall back to the method allocator.
764-
if (allocator == nullptr || allocator->size() == 0) {
764+
if (allocator == nullptr || allocator->size() == 0 ||
765+
allocator->size() < (sizeof(TensorMeta) * n_args) +
766+
(sizeof(executorch::aten::DimOrderType) * kTensorDimensionLimit *
767+
n_args)) {
765768
allocator = memory_manager_->method_allocator();
766769
}
767770
TensorMeta* meta = allocator->allocateList<TensorMeta>(n_args);

0 commit comments

Comments
 (0)