From 5d3ad40d114bab9c9c6911e469304e6948bc1975 Mon Sep 17 00:00:00 2001 From: Pete Warden Date: Thu, 21 May 2020 11:27:43 -0700 Subject: [PATCH] Fix for hello_world memory error PiperOrigin-RevId: 312707164 Change-Id: Ibdc1b5bd2161daa093cc79f165c03ac5a6c99acc --- .../lite/micro/examples/hello_world/main_functions.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tensorflow/lite/micro/examples/hello_world/main_functions.cc b/tensorflow/lite/micro/examples/hello_world/main_functions.cc index 404c8542432..d1c2cafe850 100644 --- a/tensorflow/lite/micro/examples/hello_world/main_functions.cc +++ b/tensorflow/lite/micro/examples/hello_world/main_functions.cc @@ -34,8 +34,12 @@ TfLiteTensor* output = nullptr; int inference_count = 0; // Create an area of memory to use for input, output, and intermediate arrays. -// Finding the minimum value for your model may require some trial and error. -constexpr int kTensorArenaSize = 2 * 1024; +// Minimum arena size, at the time of writing. After allocating tensors +// you can retrieve this value by invoking interpreter.arena_used_bytes(). +const int kModelArenaSize = 2352; +// Extra headroom for model + alignment + future interpreter changes. +const int kExtraArenaSize = 560 + 16 + 100; +const int kTensorArenaSize = kModelArenaSize + kExtraArenaSize; uint8_t tensor_arena[kTensorArenaSize]; } // namespace