@@ -6,9 +6,9 @@ Subject: [Executorch 6/7] Add executorch_runner test
66---
77 applications/CMakeLists.txt | 2 +
88 applications/executorch_tests/CMakeLists.txt | 76 +++++++++++
9- applications/executorch_tests/runner.cpp | 133 +++++++++++++++++++
9+ applications/executorch_tests/runner.cpp | 136 +++++++++++++++++++
1010 cmake/helpers.cmake | 13 +-
11- 4 files changed, 222 insertions(+), 2 deletions(-)
11+ 4 files changed, 225 insertions(+), 2 deletions(-)
1212 create mode 100644 applications/executorch_tests/CMakeLists.txt
1313 create mode 100644 applications/executorch_tests/runner.cpp
1414
@@ -17,9 +17,9 @@ index 1fa2b2e..68e5427 100644
1717--- a/applications/CMakeLists.txt
1818+++ b/applications/CMakeLists.txt
1919@@ -28,6 +28,8 @@ add_subdirectory(threadx_demo)
20-
20+
2121 add_subdirectory(message_handler_openamp)
22-
22+
2323+ add_subdirectory(executorch_tests)
2424+
2525 if (CMAKE_CXX_COMPILER_ID STREQUAL "ARMClang")
@@ -109,10 +109,10 @@ index 0000000..c95d53e
109109+ # TODO Memory setup
110110diff --git a/applications/executorch_tests/runner.cpp b/applications/executorch_tests/runner.cpp
111111new file mode 100644
112- index 0000000..7ef920d
112+ index 0000000..4f9d334
113113--- /dev/null
114114+++ b/applications/executorch_tests/runner.cpp
115- @@ -0,0 +1,133 @@
115+ @@ -0,0 +1,136 @@
116116+ /* Copyright (c) Meta Platforms, Inc. and affiliates.
117117+ * All rights reserved.
118118+ *
@@ -125,11 +125,11 @@ index 0000000..7ef920d
125125+ #include <memory>
126126+
127127+ #include <executorch/extension/data_loader/buffer_data_loader.h>
128+ + #include <executorch/extension/runner_util/inputs.h>
128129+ #include <executorch/runtime/executor/program.h>
129130+ #include <executorch/runtime/platform/log.h>
130131+ #include <executorch/runtime/platform/platform.h>
131132+ #include <executorch/runtime/platform/runtime.h>
132- + #include <executorch/util/util.h>
133133+
134134+ // Model file - TODO make this configurable through CMake
135135+ #include "model_pte.h"
@@ -224,7 +224,10 @@ index 0000000..7ef920d
224224+ ET_LOG(Info,"Method loaded.");
225225+
226226+ ET_LOG(Info,"Preparing inputs...");
227- + auto inputs = torch::executor::util::PrepareInputTensors(*method);
227+ + auto inputs = torch::executor::util::prepare_input_tensors(*method);
228+ + if (!inputs.ok()) {
229+ + ET_LOG(Info, "Preparing inputs tensors for method %s failed with status 0x%" PRIx32, method_name, inputs.error());
230+ + }
228231+ ET_LOG(Info,"Input prepared.");
229232+
230233+ ET_LOG(Info,"Starting the model execution...");
@@ -252,17 +255,17 @@ index a21d9f0..036f189 100644
252255+++ b/cmake/helpers.cmake
253256@@ -85,7 +85,7 @@ endfunction()
254257 #############################################################################
255-
258+
256259 function(ethosu_add_executable target)
257260- cmake_parse_arguments(ARGS "" "TARGET_LIBRARY" "SOURCES;LIBRARIES" ${ARGN})
258261+ cmake_parse_arguments(ARGS "WHOLE_ARCHIVE" "TARGET_LIBRARY" "SOURCES;LIBRARIES" ${ARGN})
259262 add_executable(${target})
260-
263+
261264 target_sources(${target} PRIVATE
262265@@ -95,8 +95,17 @@ function(ethosu_add_executable target)
263266 set(ARGS_TARGET_LIBRARY ethosu_target_init)
264267 endif()
265-
268+
266269+ if (ARGS_WHOLE_ARCHIVE)
267270+ set(PRE_LINKER_FLAGS "-Wl,--whole-archive")
268271+ set(POST_LINKER_FLAGS "-Wl,--no-whole-archive")
@@ -271,13 +274,12 @@ index a21d9f0..036f189 100644
271274 target_link_libraries(${target} PRIVATE
272275- ${ARGS_TARGET_LIBRARY} ${ARGS_LIBRARIES})
273276+ ${PRE_LINKER_FLAGS}
274- + ${ARGS_TARGET_LIBRARY}
277+ + ${ARGS_TARGET_LIBRARY}
275278+ ${ARGS_LIBRARIES}
276279+ ${POST_LINKER_FLAGS}
277280+ )
278-
281+
279282 ethosu_eval_link_options(${target})
280-
281- - -
282- 2.42.0
283283
284+ - -
285+ 2.42.0
0 commit comments