Skip to content

Commit

Permalink
add to gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlin54 committed Nov 12, 2024
1 parent b8b5146 commit 129e2ce
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug.apk
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug-androidTest.apk
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
curl -o android-test-debug.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/app-debug.apk
curl -o android-test-debug-androidTest.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/app-debug-androidTest.apk
unzip model.zip
mv *.pte model.pte
Expand Down
10 changes: 10 additions & 0 deletions build/build_android_llm_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ build_android_demo_apps() {
pushd extension/benchmark/android/benchmark
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew build assembleAndroidTest
popd

pushd extension/android_test
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew testDebugUnitTest
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew build assembleAndroidTest
popd
}

collect_artifacts_to_be_uploaded() {
Expand All @@ -158,6 +163,11 @@ collect_artifacts_to_be_uploaded() {
mkdir -p "${MINIBENCH_APP_DIR}"
cp extension/benchmark/android/benchmark/app/build/outputs/apk/debug/*.apk "${MINIBENCH_APP_DIR}"
cp extension/benchmark/android/benchmark/app/build/outputs/apk/androidTest/debug/*.apk "${MINIBENCH_APP_DIR}"
# Collect Java library test
JAVA_LIBRARY_TEST_DIR="${ARTIFACTS_DIR_NAME}/library_test_dir"
mkdir -p "${JAVA_LIBRARY_TEST_DIR}"
cp extension/android_test/build/outputs/apk/debug/*.apk "${JAVA_LIBRARY_TEST_DIR}"
cp extension/android_test/build/outputs/apk/androidTest/debug/*.apk "${JAVA_LIBRARY_TEST_DIR}"
}

main() {
Expand Down
5 changes: 5 additions & 0 deletions build/run_android_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ adb shell mkdir -p /data/local/tmp/llama
adb push model.pte /data/local/tmp/llama
adb push tokenizer.bin /data/local/tmp/llama
adb shell am instrument -w -r com.example.executorchllamademo.test/androidx.test.runner.AndroidJUnitRunner

adb install -t android-test-debug.apk
adb install -t android-test-debug-androidTest.apk

adb shell am instrument -w -r org.pytorch.executorch.test/androidx.test.runner.AndroidJUnitRunner
25 changes: 8 additions & 17 deletions extension/android_test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,21 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
}
plugins {
id("com.android.application") version "8.1.0" apply false
}


apply plugin: 'com.android.library'

group 'org.pytorch.executorch'

apply plugin: "com.android.application"

android {
namespace 'org.pytorch.executorch'
compileSdkVersion 31
buildToolsVersion "29.0.0"
compileSdk = 34

defaultConfig {
minSdkVersion 28
targetSdkVersion 31
minSdk = 28
targetSdk = 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -57,7 +48,7 @@ dependencies {
}

task('setupNativeLibs', type: Exec){
commandLine("sh", "setup.sh")
commandLine("bash", "setup.sh")
}

gradle.projectsEvaluated {
Expand Down
4 changes: 3 additions & 1 deletion extension/android_test/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
Expand All @@ -16,6 +16,7 @@ source "$BASEDIR"/../../build/build_android_llm_demo.sh
build_native_library() {
ANDROID_ABI="$1"
CMAKE_OUT="cmake-out-android-${ANDROID_ABI}"
ANDROID_NDK="${ANDROID_NDK:-/opt/ndk}"
EXECUTORCH_CMAKE_BUILD_TYPE="${EXECUTORCH_CMAKE_BUILD_TYPE:-Release}"
cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
Expand Down Expand Up @@ -52,6 +53,7 @@ build_jar
build_native_library "arm64-v8a"
build_native_library "x86_64"
build_aar
bash examples/models/llama/install_requirements.sh
source ".ci/scripts/test_llama.sh" stories110M cmake fp16 portable ${BUILD_AAR_DIR}
popd
mkdir -p "$BASEDIR"/src/libs
Expand Down

0 comments on commit 129e2ce

Please sign in to comment.