[PATCH] D135743: Move interpreter check before modifying the allocation type.

Jacob Hegna via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 21:37:13 PDT 2022


jacobhegna created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
jacobhegna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135743

Files:
  llvm/lib/Analysis/TFLiteUtils.cpp


Index: llvm/lib/Analysis/TFLiteUtils.cpp
===================================================================
--- llvm/lib/Analysis/TFLiteUtils.cpp
+++ llvm/lib/Analysis/TFLiteUtils.cpp
@@ -121,6 +121,11 @@
   tflite::InterpreterBuilder Builder(*Model, Resolver);
   Builder(&Interpreter);
 
+  if (!Interpreter) {
+    invalidate();
+    return;
+  }
+
   // We assume the input buffers are valid for the lifetime of the interpreter.
   // By default, tflite allocates memory in an arena and will periodically take
   // away memory and reallocate it in a different location after evaluations in
@@ -130,8 +135,7 @@
     Interpreter->tensor(I)->allocation_type =
         TfLiteAllocationType::kTfLiteArenaRwPersistent;
 
-  if (!Interpreter ||
-      Interpreter->AllocateTensors() != TfLiteStatus::kTfLiteOk) {
+  if (Interpreter->AllocateTensors() != TfLiteStatus::kTfLiteOk) {
     invalidate();
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135743.467008.patch
Type: text/x-patch
Size: 918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221012/c3c9a5d8/attachment.bin>


More information about the llvm-commits mailing list