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 8set -ex 9 10# https://github.com/pytorch/executorch/tree/main/examples/demo-apps/android/ExecuTorchDemo 11export_model() { 12 MODEL_NAME=dl3 13 # Delegating DeepLab v3 to XNNPACK backend 14 python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate 15 16 ASSETS_DIR=examples/demo-apps/android/ExecuTorchDemo/app/src/main/assets/ 17 mkdir -p "${ASSETS_DIR}" 18 cp "${MODEL_NAME}_xnnpack_fp32.pte" "${ASSETS_DIR}" 19} 20 21build_android_demo_app() { 22 mkdir -p examples/demo-apps/android/ExecuTorchDemo/app/libs 23 cp executorch.aar examples/demo-apps/android/ExecuTorchDemo/app/libs 24 pushd examples/demo-apps/android/ExecuTorchDemo 25 ANDROID_HOME=/opt/android/sdk ./gradlew build 26 popd 27} 28 29export_model 30build_android_demo_app 31