Skip to content

Commit 5cb625a

Browse files
committed
Update
[ghstack-poisoned]
1 parent f351ec2 commit 5cb625a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

examples/portable/executor_runner/executor_runner.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,24 @@ int main(int argc, char** argv) {
249249
(uint32_t)method.error());
250250
ET_LOG(Info, "Method loaded.");
251251

252-
// Allocate input tensors and set all of their elements to 1. The `inputs`
253-
// variable owns the allocated memory and must live past the last call to
254-
// `execute()`.
255-
auto inputs = executorch::extension::prepare_input_tensors(*method);
256-
ET_CHECK_MSG(
257-
inputs.ok(),
258-
"Could not prepare inputs: 0x%" PRIx32,
259-
(uint32_t)inputs.error());
260-
ET_LOG(Info, "Inputs prepared.");
261-
262252
// Run the model.
263253
for (uint32_t i = 0; i < FLAGS_num_executions; i++) {
254+
ET_LOG(Info, "Preparing inputs.");
255+
// Allocate input tensors and set all of their elements to 1. The `inputs`
256+
// variable owns the allocated memory and must live past the last call to
257+
// `execute()`.
258+
//
259+
// NOTE: we have to re-prepare input tensors on every execution
260+
// because inputs whose space gets reused by memory planning (if
261+
// any such inputs exist) will not be preserved for the next
262+
// execution.
263+
auto inputs = executorch::extension::prepare_input_tensors(*method);
264+
ET_CHECK_MSG(
265+
inputs.ok(),
266+
"Could not prepare inputs: 0x%" PRIx32,
267+
(uint32_t)inputs.error());
268+
ET_LOG(Info, "Inputs prepared.");
269+
264270
Error status = method->execute();
265271
ET_CHECK_MSG(
266272
status == Error::Ok,

0 commit comments

Comments
 (0)