From c23c4e135b8982904b300feadbbd96fbf293398f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Nilsson?= Date: Tue, 4 Apr 2023 16:39:42 +0200 Subject: Inference app: Call external context after allocate tensors TFLM now mandates to set external context during prepare or invoke state. Change-Id: I87d3f386aac5c47b71a7abfb9a8c48ff0255fc67 --- applications/inference_process/src/inference_process.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/inference_process/src/inference_process.cpp b/applications/inference_process/src/inference_process.cpp index a5bf642..3cbc8e0 100644 --- a/applications/inference_process/src/inference_process.cpp +++ b/applications/inference_process/src/inference_process.cpp @@ -158,11 +158,6 @@ bool InferenceProcess::runJob(InferenceJob &job) { tflite::ArmProfiler profiler; tflite::MicroInterpreter interpreter(model, resolver, tensorArena, tensorArenaSize, nullptr, &profiler); - // Set external context - if (job.externalContext != nullptr) { - interpreter.SetMicroExternalContext(job.externalContext); - } - // Allocate tensors TfLiteStatus status = interpreter.AllocateTensors(); if (status != kTfLiteOk) { @@ -170,6 +165,11 @@ bool InferenceProcess::runJob(InferenceJob &job) { return true; } + // Set external context + if (job.externalContext != nullptr) { + interpreter.SetMicroExternalContext(job.externalContext); + } + // Copy IFM data from job descriptor to TFLu arena if (copyIfm(job, interpreter)) { return true; -- cgit v1.2.1