[PATCH] D135739: [MLGO] Force persistency in tflite buffers.

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


jacobhegna updated this revision to Diff 467009.
jacobhegna added a comment.

Move interpreter check before modifying the allocation type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135739/new/

https://reviews.llvm.org/D135739

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: D135739.467009.patch
Type: text/x-patch
Size: 918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221012/edd09a92/attachment.bin>


More information about the llvm-commits mailing list