From 5cb625abcaf55c2145021cd098d41b45bb1ca184 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Mon, 17 Mar 2025 16:03:04 -0700 Subject: [PATCH 1/2] Update [ghstack-poisoned] --- .../executor_runner/executor_runner.cpp | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/examples/portable/executor_runner/executor_runner.cpp b/examples/portable/executor_runner/executor_runner.cpp index 1e0241958b9..ad8c159a7be 100644 --- a/examples/portable/executor_runner/executor_runner.cpp +++ b/examples/portable/executor_runner/executor_runner.cpp @@ -249,18 +249,24 @@ int main(int argc, char** argv) { (uint32_t)method.error()); ET_LOG(Info, "Method loaded."); - // Allocate input tensors and set all of their elements to 1. The `inputs` - // variable owns the allocated memory and must live past the last call to - // `execute()`. - auto inputs = executorch::extension::prepare_input_tensors(*method); - ET_CHECK_MSG( - inputs.ok(), - "Could not prepare inputs: 0x%" PRIx32, - (uint32_t)inputs.error()); - ET_LOG(Info, "Inputs prepared."); - // Run the model. for (uint32_t i = 0; i < FLAGS_num_executions; i++) { + ET_LOG(Info, "Preparing inputs."); + // Allocate input tensors and set all of their elements to 1. The `inputs` + // variable owns the allocated memory and must live past the last call to + // `execute()`. + // + // NOTE: we have to re-prepare input tensors on every execution + // because inputs whose space gets reused by memory planning (if + // any such inputs exist) will not be preserved for the next + // execution. + auto inputs = executorch::extension::prepare_input_tensors(*method); + ET_CHECK_MSG( + inputs.ok(), + "Could not prepare inputs: 0x%" PRIx32, + (uint32_t)inputs.error()); + ET_LOG(Info, "Inputs prepared."); + Error status = method->execute(); ET_CHECK_MSG( status == Error::Ok, From ac789abf1d728bbc39690642a51904aa169b1269 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Mon, 17 Mar 2025 16:17:13 -0700 Subject: [PATCH 2/2] Update [ghstack-poisoned] --- examples/portable/executor_runner/executor_runner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/portable/executor_runner/executor_runner.cpp b/examples/portable/executor_runner/executor_runner.cpp index ad8c159a7be..08907d333c4 100644 --- a/examples/portable/executor_runner/executor_runner.cpp +++ b/examples/portable/executor_runner/executor_runner.cpp @@ -251,7 +251,7 @@ int main(int argc, char** argv) { // Run the model. for (uint32_t i = 0; i < FLAGS_num_executions; i++) { - ET_LOG(Info, "Preparing inputs."); + ET_LOG(Debug, "Preparing inputs."); // Allocate input tensors and set all of their elements to 1. The `inputs` // variable owns the allocated memory and must live past the last call to // `execute()`. @@ -265,7 +265,7 @@ int main(int argc, char** argv) { inputs.ok(), "Could not prepare inputs: 0x%" PRIx32, (uint32_t)inputs.error()); - ET_LOG(Info, "Inputs prepared."); + ET_LOG(Debug, "Inputs prepared."); Error status = method->execute(); ET_CHECK_MSG(