Skip to content

ET App #2685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

ET App #2685

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions examples/demo-apps/android/ExecuTorchDemo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ cp deeplab_v3/dlv3_qnn.pte examples/demo-apps/android/ExecuTorchDemo/app/src/mai

We build the required ExecuTorch runtime library to run the model.

#### Java helper classes

Note: This is an ad-hoc solution. We will publish a formal Java package when it is ready. However, for now we need to copy sources from extension/android/src/main/java/org/pytorch/executorch.

```
mkdir -p examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/executor
cp extension/android/src/main/java/org/pytorch/executorch/*.java examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/executor
```

#### XNNPACK

1. Configure the CMake target for the library with XNNPACK backend:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ dependencies {
implementation("androidx.constraintlayout:constraintlayout:2.2.0-alpha12")
implementation("com.facebook.soloader:soloader:0.10.5")
implementation("com.facebook.fbjni:fbjni:0.5.1")
implementation("org.pytorch.executorch:executorch") {
exclude("com.facebook.fbjni", "fbjni-java-only")
}
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.pytorch.executorch.EValue;
import org.pytorch.executorch.Module;
import org.pytorch.executorch.Tensor;
import org.pytorch.executorch.TensorImageUtils;

public class MainActivity extends Activity implements Runnable {
private ImageView mImageView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* LICENSE file in the root directory of this source tree.
*/

package org.pytorch.executorch;
package com.example.executorchdemo;

import android.graphics.Bitmap;
import android.util.Log;
import java.nio.FloatBuffer;
import org.pytorch.executorch.Tensor;

/**
* Contains utility functions for {@link Tensor} creation from {@link android.graphics.Bitmap} or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ dependencyResolutionManagement {
rootProject.name = "ExecuTorch Demo"

include(":app")

includeBuild("../../../../extension/android")
5 changes: 0 additions & 5 deletions examples/demo-apps/android/ExecuTorchDemo/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

set -eu

EXECUTOR_JAVA_DIR=examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/executor/
mkdir -p "${EXECUTOR_JAVA_DIR}"
# Temporary workaround until we have a formal Java package
cp extension/android/src/main/java/org/pytorch/executorch/*.java "${EXECUTOR_JAVA_DIR}"

pushd cmake-out
# Note: Set up ANDROID_NDK, ANDROID_ABI, BUCK2, and FLATC_EXECUTABLE
cmake .. -DCMAKE_INSTALL_PREFIX=cmake-out \
Expand Down
4 changes: 3 additions & 1 deletion examples/demo-apps/android/LlamaDemo/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.camera:camera-core:1.3.0-rc02")
implementation("androidx.constraintlayout:constraintlayout:2.2.0-alpha12")
implementation("com.facebook.soloader:soloader:0.10.5")
implementation("com.facebook.fbjni:fbjni:0.5.1")
implementation("org.pytorch.executorch:executorch") {
exclude("com.facebook.fbjni", "fbjni-java-only")
}
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
2 changes: 2 additions & 0 deletions examples/demo-apps/android/LlamaDemo/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ dependencyResolutionManagement {
rootProject.name = "ExecuTorch Demo"

include(":app")

includeBuild("../../../../extension/android")
10 changes: 10 additions & 0 deletions extension/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

plugins {
id 'java-library'
}

group 'org.pytorch.executorch'

repositories {
mavenCentral()
}
Expand Down