Skip to content

Commit b49b052

Browse files
committed
Arm backend: Adding run_vmkl.sh script
Signed-off-by: Rob Elliott <[email protected]> Change-Id: I24b31ec7e31c2230cf7d48bbf03cd5f81dd064ba
1 parent 8bab0d1 commit b49b052

File tree

2 files changed

+96
-5
lines changed

2 files changed

+96
-5
lines changed

backends/arm/scripts/run_vkml.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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}"

examples/arm/setup.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,17 @@ function create_setup_path(){
372372
cd "${root_dir}"
373373
model_vgf_path="$(cd ${mlsdk_manifest_dir}/sw/vgf-lib/deploy && pwd)"
374374
echo "export PATH=\${PATH}:${model_vgf_path}/bin" >> ${setup_path_script}
375-
echo "export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${model_vgf_path}/lib" >> ${setup_path_script}
376-
echo "export DYLD_LIBRARY_PATH=\${DYLD_LIBRARY_PATH}:${model_vgf_path}/lib" >> ${setup_path_script}
375+
echo "export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH-}:${model_vgf_path}/lib" >> ${setup_path_script}
376+
echo "export DYLD_LIBRARY_PATH=\${DYLD_LIBRARY_PATH-}:${model_vgf_path}/lib" >> ${setup_path_script}
377377
fi
378378

379379
if [[ "${enable_emulation_layer}" -eq 1 ]]; then
380380
cd "${root_dir}"
381381
model_emulation_layer_path="$(cd ${mlsdk_manifest_dir}/sw/emulation-layer/ && pwd)"
382382
echo "export LD_LIBRARY_PATH=${model_emulation_layer_path}/deploy/lib:\${LD_LIBRARY_PATH}" >> ${setup_path_script}
383-
echo "export DYLD_LIBRARY_PATH=${model_emulation_layer_path}/deploy/lib:\${DYLD_LIBRARY_PATH}" >> ${setup_path_script}
384-
echo "export VK_INSTANCE_LAYERS=VK_LAYER_ML_Graph_Emulation:VK_LAYER_ML_Tensor_Emulation:\${VK_INSTANCE_LAYERS}" >> ${setup_path_script}
385-
echo "export VK_ADD_LAYER_PATH=${model_emulation_layer_path}/deploy/share/vulkan/explicit_layer.d:\${VK_ADD_LAYER_PATH}" >> ${setup_path_script}
383+
echo "export DYLD_LIBRARY_PATH=${model_emulation_layer_path}/deploy/lib:\${DYLD_LIBRARY_PATH-}" >> ${setup_path_script}
384+
echo "export VK_INSTANCE_LAYERS=VK_LAYER_ML_Graph_Emulation:VK_LAYER_ML_Tensor_Emulation:\${VK_INSTANCE_LAYERS-}" >> ${setup_path_script}
385+
echo "export VK_ADD_LAYER_PATH=${model_emulation_layer_path}/deploy/share/vulkan/explicit_layer.d:\${VK_ADD_LAYER_PATH-}" >> ${setup_path_script}
386386
fi
387387
}
388388

0 commit comments

Comments
 (0)