xref: /aosp_15_r20/external/executorch/build/test_android_ci.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1*523fa7a6SAndroid Build Coastguard Worker#!/bin/bash
2*523fa7a6SAndroid Build Coastguard Worker# Copyright (c) Meta Platforms, Inc. and affiliates.
3*523fa7a6SAndroid Build Coastguard Worker# All rights reserved.
4*523fa7a6SAndroid Build Coastguard Worker#
5*523fa7a6SAndroid Build Coastguard Worker# This source code is licensed under the BSD-style license found in the
6*523fa7a6SAndroid Build Coastguard Worker# LICENSE file in the root directory of this source tree.
7*523fa7a6SAndroid Build Coastguard Worker
8*523fa7a6SAndroid Build Coastguard Workerset -ex
9*523fa7a6SAndroid Build Coastguard Worker
10*523fa7a6SAndroid Build Coastguard Worker# https://github.com/pytorch/executorch/tree/main/examples/demo-apps/android/ExecuTorchDemo
11*523fa7a6SAndroid Build Coastguard Workerexport_model() {
12*523fa7a6SAndroid Build Coastguard Worker  MODEL_NAME=dl3
13*523fa7a6SAndroid Build Coastguard Worker  # Delegating DeepLab v3 to XNNPACK backend
14*523fa7a6SAndroid Build Coastguard Worker  python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate
15*523fa7a6SAndroid Build Coastguard Worker
16*523fa7a6SAndroid Build Coastguard Worker  ASSETS_DIR=examples/demo-apps/android/ExecuTorchDemo/app/src/main/assets/
17*523fa7a6SAndroid Build Coastguard Worker  mkdir -p "${ASSETS_DIR}"
18*523fa7a6SAndroid Build Coastguard Worker  cp "${MODEL_NAME}_xnnpack_fp32.pte" "${ASSETS_DIR}"
19*523fa7a6SAndroid Build Coastguard Worker}
20*523fa7a6SAndroid Build Coastguard Worker
21*523fa7a6SAndroid Build Coastguard Workerbuild_android_demo_app() {
22*523fa7a6SAndroid Build Coastguard Worker  mkdir -p examples/demo-apps/android/ExecuTorchDemo/app/libs
23*523fa7a6SAndroid Build Coastguard Worker  cp executorch.aar examples/demo-apps/android/ExecuTorchDemo/app/libs
24*523fa7a6SAndroid Build Coastguard Worker  pushd examples/demo-apps/android/ExecuTorchDemo
25*523fa7a6SAndroid Build Coastguard Worker  ANDROID_HOME=/opt/android/sdk ./gradlew build
26*523fa7a6SAndroid Build Coastguard Worker  popd
27*523fa7a6SAndroid Build Coastguard Worker}
28*523fa7a6SAndroid Build Coastguard Worker
29*523fa7a6SAndroid Build Coastguard Workerexport_model
30*523fa7a6SAndroid Build Coastguard Workerbuild_android_demo_app
31