[PATCH] D135739: [MLGO] Force persistency in tflite buffers.
Jacob Hegna via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 12:50:56 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d93a98f853a: [MLGO] Force persistency in tflite buffers. (authored by jacobhegna).
Changed prior to commit:
https://reviews.llvm.org/D135739?vs=467009&id=467239#toc
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,15 @@
tflite::InterpreterBuilder Builder(*Model, Resolver);
Builder(&Interpreter);
+ // 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
+ // order to improve utilization of the buffers owned in the arena. So, we
+ // explicitly mark our input buffers as persistent to avoid this behavior.
+ for (size_t I = 0; I < Interpreter->inputs().size(); ++I)
+ Interpreter->tensor(I)->allocation_type =
+ TfLiteAllocationType::kTfLiteArenaRwPersistent;
+
if (!Interpreter ||
Interpreter->AllocateTensors() != TfLiteStatus::kTfLiteOk) {
invalidate();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135739.467239.patch
Type: text/x-patch
Size: 966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221012/b626593c/attachment.bin>
More information about the llvm-commits
mailing list