Skip to content

Commit

Permalink
@tensorflow/micro
Browse files Browse the repository at this point in the history
Handle the failure to allocate temporary memory for a TfLiteTensor in a more graceful way.  This allows most kernels in the Prepare phase to not crash due to a DCHECK on memory allocation failure.

bug=fixes Bugfix: unchecked pointer use tensorflow#3057
  • Loading branch information
ddavis-2015 committed Mar 6, 2025
1 parent ef64591 commit 7ba7fb1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tensorflow/lite/micro/micro_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,11 @@ TfLiteTensor* MicroAllocator::AllocateTempTfLiteTensor(
TfLiteTensor* tensor = reinterpret_cast<TfLiteTensor*>(
non_persistent_buffer_allocator_->AllocateTemp(sizeof(TfLiteTensor),
alignof(TfLiteTensor)));
if (tensor == nullptr) {
MicroPrintf("Failed to allocate temp. memory for tensor %d, subgraph %d",
tensor_index, subgraph_index);
return nullptr;
}

// Populate any fields from the flatbuffer, since this TfLiteTensor struct is
// allocated in the temp section of the arena, ensure that additional
Expand Down

0 comments on commit 7ba7fb1

Please sign in to comment.