From 67d4e03fad558c90334037e915ffa93c126ea19a Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 27 Feb 2025 15:52:42 -0800 Subject: [PATCH 1/2] [Android docs] Minor update to existing sections --- docs/source/using-executorch-android.md | 36 +++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/source/using-executorch-android.md b/docs/source/using-executorch-android.md index e41cd3e2bb7..af3c327fcbe 100644 --- a/docs/source/using-executorch-android.md +++ b/docs/source/using-executorch-android.md @@ -1,16 +1,26 @@ # Using ExecuTorch on Android -To use from Android, ExecuTorch provides Java API bindings and Android platform integration, available as a AAR file. The ExecuTorch C++ APIs can also be used from Android native. +To use from Android, ExecuTorch provides Java/Kotlin API bindings and Android platform integration, available as an AAR file. + +Note: This page covers Android app integration through the AAR library. The ExecuTorch C++ APIs can also be used from Android native, and the documentation can be found on [this page about cross compilation](https://pytorch.org/executorch/main/using-executorch-building-from-source.html#cross-compilation). ## Installation -We provide a prebuilt Android library (AAR), `executorch.aar` for both generic (image/audio processing) and LLAMA use case. +We package all ExecuTorch Android libraries into an Android library (AAR), `executorch.aar` for both generic (image/audio processing) and LLM (LLaMA) use case. In each release, we will upload the prebuilt AAR artifacts. Users can also build the AAR from source. + +### Contents of library -## Contents of library -- `executorch.aar` - - [Java library](https://github.com/pytorch/executorch/tree/main/extension/android/src/main/java/org/pytorch/executorch) - - JNI contains the JNI binding for the corresponding Java code, and ExecuTorch native library, including core ExecuTorch runtime libraries, XNNPACK backend, Portable kernels, Optimized kernels, Quantized kernels, and LLAMA-specific Custom ops library. - - Comes with two ABI variants, arm64-v8a and x86\_64. +The AAR artifact contains the Java library for users to integrate with their Java/Kotlin application code, as well as the corresponding JNI library (.so file), which is loaded by the Java code during initialization. + +- [Java library](https://github.com/pytorch/executorch/tree/main/extension/android/src/main/java/org/pytorch/executorch) +- JNI contains the JNI binding for the corresponding Java code, and ExecuTorch native library, including + - core ExecuTorch runtime libraries + - XNNPACK backend + - Portable kernels + - Optimized kernels + - Quantized kernels + - LLaMa-specific Custom ops library. +- Comes with two ABI variants, arm64-v8a and x86\_64. ## Downloading AAR @@ -30,10 +40,18 @@ We provide a prebuilt Android library (AAR), `executorch.aar` for both generic ( To add the Java library to your app, simply download the AAR, and add it to your gradle build rule. +The Java package requires `fbjni` and `soloader`, and currently requires users to explicitly declare the dependency. Therefore, two more `dependencies` in gradle rule is required: +``` +implementation("com.facebook.soloader:soloader:0.10.5") +implementation("com.facebook.fbjni:fbjni:0.5.1") +``` + +### Example usage + In your app working directory, such as example executorch/examples/demo-apps/android/LlamaDemo, ``` mkdir -p app/libs -curl https://ossci-android.s3.amazonaws.com/executorch/release/executorch-241002/executorch.aar -o app/libs/executorch.aar +curl https://ossci-android.s3.amazonaws.com/executorch/release/v0.5.0-rc3/executorch.aar -o app/libs/executorch.aar ``` And include it in gradle: @@ -41,6 +59,8 @@ And include it in gradle: # app/build.grardle.kts dependencies { implementation(files("libs/executorch.aar")) + implementation("com.facebook.soloader:soloader:0.10.5") + implementation("com.facebook.fbjni:fbjni:0.5.1") } ``` From 64dbfa8df68ddafb1a9d53000fe663bb758f9796 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 27 Feb 2025 16:04:35 -0800 Subject: [PATCH 2/2] Update --- docs/source/using-executorch-android.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/using-executorch-android.md b/docs/source/using-executorch-android.md index af3c327fcbe..e8579db1e6f 100644 --- a/docs/source/using-executorch-android.md +++ b/docs/source/using-executorch-android.md @@ -38,7 +38,9 @@ The AAR artifact contains the Java library for users to integrate with their Jav ## Using prebuilt libraries -To add the Java library to your app, simply download the AAR, and add it to your gradle build rule. +To add the Java library to your app: +1. Download the AAR. +2. Add it to your gradle build rule as a file path. The Java package requires `fbjni` and `soloader`, and currently requires users to explicitly declare the dependency. Therefore, two more `dependencies` in gradle rule is required: ``` @@ -48,7 +50,7 @@ implementation("com.facebook.fbjni:fbjni:0.5.1") ### Example usage -In your app working directory, such as example executorch/examples/demo-apps/android/LlamaDemo, +In your app working directory, such as executorch/examples/demo-apps/android/LlamaDemo, ``` mkdir -p app/libs curl https://ossci-android.s3.amazonaws.com/executorch/release/v0.5.0-rc3/executorch.aar -o app/libs/executorch.aar