Build and run the executor runner
ExecuTorch uses CMake to configure its C and C++ builds. CMake generates the build instructions used by tools such as Ninja or
Make. Here, build_executor_runner.sh supplies CMake with the Arm cross-compiler toolchain, Corstone-320 target settings, feature options, and the selected .pte artifact. The generated build then compiles the runner and
ExecuTorch runtime, links the Ethos-U delegate and supporting libraries, and
embeds the model in the final bare-metal ELF.
The runner handles the embedded ExecuTorch runtime sequence on behalf of the application. In simplified form, the relevant calls are:
executorch::runtime::runtime_init();
Result<Program> program = Program::load(&loader);
Result<Method> method = program->load_method("forward", &memory_manager);
method->execute();
runtime_init() initializes the platform runtime, Program::load() parses
the .pte data, and load_method() creates the executable method using the
supplied memory manager. Method::execute() runs that method. The Arm executor
runner includes error handling, input setup, and allocator management around
these calls.
Build a runner containing the baseline INT8 .pte artifact:
~/executorch/backends/arm/scripts/build_executor_runner.sh \
--pte="$PWD/module-4-ethos-npu-accelerated-inference/artifacts/mobilenetv2/mobilenetv2_int8_ethosu.pte" \
--target=ethos-u85-256 \
--system_config=Ethos_U85_SYS_DRAM_Mid \
--memory_mode=Shared_Sram \
--extra_build_flags="-DSEMIHOSTING=ON -DET_ARM_BAREMETAL_SEMIHOSTING_FILE_ALLOCATOR_POOL_SIZE=0x01000000" \
--output="$PWD/module-4-ethos-npu-accelerated-inference/artifacts/fvp_runner/mobilenetv2_int8"
The linker can report .ddr, .sram, RWX segment, or ETHOSU_MODEL
redefinition warnings. Continue if the command finishes with
Built target arm_executor_runner and prints the generated ELF path.
The build embeds the .pte artifact in this ELF:
module-4-ethos-npu-accelerated-inference/artifacts/fvp_runner/mobilenetv2_int8/arm_executor_runner
Run the FVP
The FVP run uses semihosting: a simulator file-service mechanism that lets bare-metal code request files from the host. In this module, semihosting lets the runner read i0.bin and write out-0.bin through a directory on the Linux host. A deployed board would use its own storage, memory, sensors, or I/O path instead.
FVP_Corstone_SSE-320 \
-C mps4_board.subsystem.ethosu.num_macs=256 \
-C mps4_board.visualisation.disable-visualisation=1 \
-C vis_hdlcd.disable_visualisation=1 \
-C mps4_board.telnetterminal0.start_telnet=0 \
-C mps4_board.uart0.out_file='-' \
-C mps4_board.uart0.unbuffered_output=1 \
-C mps4_board.uart0.shutdown_on_eot=1 \
-C mps4_board.subsystem.cpu0.semihosting-enable=1 \
-C mps4_board.subsystem.cpu0.semihosting-stack_base=0 \
-C mps4_board.subsystem.cpu0.semihosting-heap_limit=0 \
-C "mps4_board.subsystem.cpu0.semihosting-cwd=$(realpath module-4-ethos-npu-accelerated-inference/artifacts/fvp_runs/mobilenetv2_int8)" \
-C "mps4_board.subsystem.cpu0.semihosting-cmd_line=executor_runner -o out -i i0.bin" \
-a "$(realpath module-4-ethos-npu-accelerated-inference/artifacts/fvp_runner/mobilenetv2_int8/arm_executor_runner)" \
--timelimit 600 \
2>&1 | tee module-4-ethos-npu-accelerated-inference/artifacts/fvp_runs/mobilenetv2_int8/mobilenetv2_int8.log
The terminal output should include lines similar to:
Reading input tensor 1 from file i0.bin
Running method forward
NPU Inferences : 1
NPU delegations: 1 (1.00 per inference)
ethosu_pmu_cycle_cntr : 2802289 (2802289.00 per inference)
Writing output to file: out-0.bin
Program complete, exiting.
This confirms that the runner loaded the program, passed the prepared image to
MobileNetV2, invoked one Ethos-U delegate, and wrote the raw model output. The
PMU counters confirm simulated NPU activity, but they are not hardware performance measurements.
The command does not enable the Ethos-U
--fast option, so the Ethos-U timing model reports NPU cycle and activity
counters. A timed simulation takes longer to run.
Course complete
Nice work
You completed Optimize and deploy AI inference with ExecuTorch on Arm.