1#!/bin/bash 2# Copyright (c) Meta Platforms, Inc. and affiliates. 3# All rights reserved. 4# 5# This source code is licensed under the BSD-style license found in the 6# LICENSE file in the root directory of this source tree. 7 8# Test the end-to-end flow of qualcomm runner. 9 10set -e 11 12# shellcheck source=/dev/null 13source "$(dirname "${BASH_SOURCE[0]}")/../../../.ci/scripts/utils.sh" 14cmake_install_executorch_qnn_lib() { 15 echo "Installing libexecutorch.a, libqnn_executorch_backend.a" 16 rm -rf cmake-out 17 18 retry cmake -DBUCK2="$BUCK" \ 19 -DCMAKE_INSTALL_PREFIX=cmake-out \ 20 -DCMAKE_BUILD_TYPE=Release \ 21 -DEXECUTORCH_BUILD_QNN=ON \ 22 -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ 23 -Bcmake-out . 24 cmake --build cmake-out -j9 --target install --config Release 25} 26 27test_cmake_qualcomm() { 28 echo "Exporting MobilenetV2" 29 ${PYTHON_EXECUTABLE} -m examples.qualcomm.scripts.export_example --model_name mv2 30 31 local example_dir=examples/qualcomm 32 local build_dir=cmake-out/${example_dir} 33 CMAKE_PREFIX_PATH="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" 34 # build qnn_executor_runner 35 rm -rf ${build_dir} 36 retry cmake \ 37 -DCMAKE_BUILD_TYPE=Release \ 38 -DQNN_SDK_ROOT=$QNN_SDK_ROOT \ 39 -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ 40 -DANDROID_ABI='arm64-v8a' \ 41 -DANDROID_NATIVE_API_LEVEL=23 \ 42 -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \ 43 -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ 44 -B${build_dir} \ 45 ${example_dir} 46 47 echo "Building ${example_dir}" 48 cmake --build ${build_dir} -j9 --config Release 49 # Need to run on device 50# ${build_dir}/qnn_executor_runner --model_path="./mv2_qnn.pte" 51} 52 53if [[ -z $PYTHON_EXECUTABLE ]]; 54then 55 PYTHON_EXECUTABLE=python3 56fi 57 58if [[ -z $BUCK ]]; 59then 60 BUCK=buck2 61fi 62 63 64cmake_install_executorch_qnn_lib 65test_cmake_qualcomm 66