|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2025 Arm Limited and/or its affiliates. |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +# Optional parameter: |
| 8 | +# --build_type= "Release" | "Debug" | "RelWithDebInfo" |
| 9 | +# --etdump build with devtools-etdump support |
| 10 | + |
| 11 | +set -eu |
| 12 | +set -o pipefail |
| 13 | + |
| 14 | +script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) |
| 15 | +et_root_dir=$(cd ${script_dir}/../../.. && pwd) |
| 16 | +et_root_dir=$(realpath ${et_root_dir}) |
| 17 | +setup_path_script=${et_root_dir}/examples/arm/ethos-u-scratch/setup_path.sh |
| 18 | +_setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly install necessary tools." |
| 19 | + |
| 20 | + |
| 21 | +model="" |
| 22 | +build_path="cmake-out" |
| 23 | +converter="model-converter" |
| 24 | + |
| 25 | +help() { |
| 26 | + echo "Usage: $(basename $0) [options]" |
| 27 | + echo "Options:" |
| 28 | + echo " --model=<MODEL_FILE> .pte model file to run" |
| 29 | + echo " --build=<BUILD_PATH> Target to build and run for Default: ${build_path}" |
| 30 | + exit 0 |
| 31 | +} |
| 32 | + |
| 33 | +for arg in "$@"; do |
| 34 | + case $arg in |
| 35 | + -h|--help) help ;; |
| 36 | + --model=*) model="${arg#*=}";; |
| 37 | + --build_path=*) build_path="${arg#*=}";; |
| 38 | + *) |
| 39 | + ;; |
| 40 | + esac |
| 41 | +done |
| 42 | + |
| 43 | +echo ${model} |
| 44 | +if [[ -z ${model} ]]; then "Model name needs to be provided"; exit 1; fi |
| 45 | + |
| 46 | + |
| 47 | +# Source the tools |
| 48 | +# This should be prepared by the setup.sh |
| 49 | +[[ -f ${setup_path_script} ]] \ |
| 50 | + || { echo "Missing ${setup_path_script}. ${_setup_msg}"; exit 1; } |
| 51 | + |
| 52 | +source ${setup_path_script} |
| 53 | + |
| 54 | +# basic checks before we get started |
| 55 | +hash ${converter} \ |
| 56 | + || { echo "Could not find ${converter} on PATH, ${_setup_msg}"; exit 1; } |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +runner="${build_path}/executor_runner" |
| 61 | + |
| 62 | +echo "--------------------------------------------------------------------------------" |
| 63 | +echo "Running ${model} with ${runner}" |
| 64 | +echo "WARNING: The VK_ML layer driver will not provide accurate performance information" |
| 65 | +echo "--------------------------------------------------------------------------------" |
| 66 | + |
| 67 | +# Check if stdbuf is intalled and use stdbuf -oL together with tee below to make the output |
| 68 | +# go all the way to the console more directly and not be buffered |
| 69 | + |
| 70 | +if hash stdbuf 2>/dev/null; then |
| 71 | + nobuf="stdbuf -oL" |
| 72 | +else |
| 73 | + nobuf="" |
| 74 | +fi |
| 75 | + |
| 76 | +log_file=$(mktemp) |
| 77 | + |
| 78 | + |
| 79 | +${runner} -model_path ${model} | tee ${log_file} |
| 80 | +echo "[${BASH_SOURCE[0]}] execution complete, $?" |
| 81 | + |
| 82 | +# Most of these can happen for bare metal or linx executor_runner runs. |
| 83 | +echo "Checking for problems in log:" |
| 84 | +! grep -E "^(F|E|\\[critical\\]|Hard fault.|Info: Simulation is stopping. Reason: CPU time has been exceeded.).*$" ${log_file} |
| 85 | +if [ $? != 0 ]; then |
| 86 | + echo "Found ERROR" |
| 87 | + rm "${log_file}" |
| 88 | + exit 1 |
| 89 | +fi |
| 90 | +echo "No problems found!" |
| 91 | +rm "${log_file}" |
0 commit comments