Skip to content

Commit

Permalink
Resync Android related BUCK file
Browse files Browse the repository at this point in the history
Pull Request resolved: #5099
  • Loading branch information
kirklandsign authored Sep 5, 2024
1 parent a8c592e commit 5156615
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 0 deletions.
67 changes: 67 additions & 0 deletions examples/demo-apps/android/ExecuTorchDemo/app/src/main/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
load("@fbsource//tools/build_defs:manifold.bzl", "manifold_get")
load("@fbsource//tools/build_defs/android:fb_android_binary.bzl", "fb_android_binary")
load("@fbsource//tools/build_defs/android:fb_android_library.bzl", "fb_android_library")
load("@fbsource//tools/build_defs/android:fb_android_resource.bzl", "fb_android_resource")

manifold_get(
name = "dl3_xnnpack_fp32",
out = "dl3_xnnpack_fp32.pte",
api_key = "executorch-key",
artifact_path = "tree/models/benchmarking/executorch/dl3_xnnpack_fp32.pte",
bucket_name = "executorch",
sha1 = "3e7af1d8f5ec4acb6de156d361715e16e5f53783",
timeout_msec = 120000,
)

fb_android_resource(
name = "app_res",
assets = "assets",
package = "com.example.executorchdemo",
res = "res",
)

fb_android_resource(
name = "model_res",
assets = {"dl3_xnnpack_fp32.pte": ":dl3_xnnpack_fp32"},
package = "com.example.executorchdemo",
res = "res",
)

fb_android_library(
name = "app_lib",
srcs = [
"java/com/example/executorchdemo/ClassificationActivity.java",
"java/com/example/executorchdemo/ImageNetClasses.java",
"java/com/example/executorchdemo/MainActivity.java",
"java/com/example/executorchdemo/TensorImageUtils.java",
],
autoglob = False,
language = "JAVA",
deps = [
":app_res",
"//xplat/executorch/extension/android:executorch",
],
)

fb_android_binary(
name = "ExecuTorchDemo",
keystore = "//fbandroid/keystores:debug",
manifest = "AndroidManifest.xml",
manifest_entries = {
"min_sdk_version": 19, # Android supports 19 for minimum
"target_sdk_version": 34,
"version_code": "1",
"version_name": "1.0",
},
package_type = "release",
skip_proguard = True,
deps = [
":app_lib",
":app_res",
":model_res",
"//third-party/java/androidx/appcompat/appcompat:appcompat",
"//third-party/java/androidx/constraintlayout/constraintlayout:constraintlayout",
"//xplat/executorch/extension/android:executorch",
"//xplat/executorch/extension/android/jni:executorch_jni_full",
],
)
64 changes: 64 additions & 0 deletions examples/demo-apps/android/LlamaDemo/app/src/main/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
load("@fbsource//tools/build_defs/android:fb_android_binary.bzl", "fb_android_binary")
load("@fbsource//tools/build_defs/android:fb_android_library.bzl", "fb_android_library")
load("@fbsource//tools/build_defs/android:fb_android_resource.bzl", "fb_android_resource")

oncall("executorch")

fb_android_resource(
name = "app_res",
package = "com.example.executorchllamademo",
res = "res",
)

fb_android_library(
name = "app_lib",
srcs = [
"java/com/example/executorchllamademo/AppLog.java",
"java/com/example/executorchllamademo/DemoSharedPreferences.java",
"java/com/example/executorchllamademo/ETImage.java",
"java/com/example/executorchllamademo/ETLogging.java",
"java/com/example/executorchllamademo/LlmBenchmarkRunner.java",
"java/com/example/executorchllamademo/LogsActivity.java",
"java/com/example/executorchllamademo/LogsAdapter.java",
"java/com/example/executorchllamademo/MainActivity.java",
"java/com/example/executorchllamademo/Message.java",
"java/com/example/executorchllamademo/MessageAdapter.java",
"java/com/example/executorchllamademo/MessageType.java",
"java/com/example/executorchllamademo/ModelRunner.java",
"java/com/example/executorchllamademo/ModelRunnerCallback.java",
"java/com/example/executorchllamademo/ModelType.java",
"java/com/example/executorchllamademo/PromptFormat.java",
"java/com/example/executorchllamademo/SettingsActivity.java",
"java/com/example/executorchllamademo/SettingsFields.java",
],
autoglob = False,
language = "JAVA",
deps = [
":app_res",
"//third-party/java/androidx/constraintlayout/constraintlayout:constraintlayout",
"//third-party/java/com/google/code/gson/gson:gson",
"//xplat/executorch/extension/android:executorch_llama",
],
)

fb_android_binary(
name = "ExecuTorchLlamaDemo",
keystore = "//fbandroid/keystores:debug",
manifest = "AndroidManifest.xml",
manifest_entries = {
"min_sdk_version": 21,
"target_sdk_version": 34,
"version_code": "1",
"version_name": "1.0",
},
package_type = "release",
skip_proguard = True,
deps = [
":app_lib",
":app_res",
"//third-party/java/androidx/appcompat/appcompat:appcompat",
"//third-party/java/com/google/code/gson/gson:gson",
"//xplat/executorch/extension/android:executorch_llama",
"//xplat/executorch/extension/android/jni:executorch_llama_jni",
],
)
34 changes: 34 additions & 0 deletions extension/android/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@fbsource//tools/build_defs/android:fb_android_library.bzl", "fb_android_library")

oncall("executorch")

fb_android_library(
name = "executorch",
srcs = [
"src/main/java/org/pytorch/executorch/DType.java",
"src/main/java/org/pytorch/executorch/EValue.java",
"src/main/java/org/pytorch/executorch/Module.java",
"src/main/java/org/pytorch/executorch/NativePeer.java",
"src/main/java/org/pytorch/executorch/Tensor.java",
],
autoglob = False,
language = "JAVA",
deps = [
"//fbandroid/java/com/facebook/jni:jni",
"//fbandroid/libraries/soloader/java/com/facebook/soloader/nativeloader:nativeloader",
],
)

fb_android_library(
name = "executorch_llama",
srcs = [
"src/main/java/org/pytorch/executorch/LlamaCallback.java",
"src/main/java/org/pytorch/executorch/LlamaModule.java",
],
autoglob = False,
language = "JAVA",
deps = [
"//fbandroid/java/com/facebook/jni:jni",
"//fbandroid/libraries/soloader/java/com/facebook/soloader/nativeloader:nativeloader",
],
)
87 changes: 87 additions & 0 deletions extension/android/jni/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
load("@fbsource//tools/build_defs/android:fb_android_cxx_library.bzl", "fb_android_cxx_library")
load("@fbsource//xplat/executorch/codegen:codegen.bzl", "executorch_generated_lib")

oncall("executorch")

executorch_generated_lib(
name = "generated_op_lib_optimized",
custom_ops_aten_kernel_deps = [
"//executorch/kernels/portable:operators_aten",
],
custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml",
define_static_targets = True,
fallback_yaml_target = "//executorch/kernels/portable:functions.yaml",
functions_yaml_target = "//executorch/kernels/optimized:optimized.yaml",
visibility = ["PUBLIC"],
deps = [
"//executorch/kernels/optimized:optimized_operators",
"//executorch/kernels/optimized:optimized_oplist",
"//executorch/kernels/portable:executorch_aten_ops",
"//executorch/kernels/portable:executorch_custom_ops",
"//executorch/kernels/portable:operators",
],
)

fb_android_cxx_library(
name = "executorch_jni",
srcs = ["jni_layer.cpp"],
headers = ["jni_layer_constants.h"],
allow_jni_merging = False,
compiler_flags = [
"-frtti",
"-fexceptions",
],
soname = "libexecutorch.$(ext)",
visibility = ["PUBLIC"],
deps = [
"//fbandroid/libraries/fbjni:fbjni",
"//fbandroid/native/fb:fb",
"//third-party/glog:glog",
"//xplat/executorch/extension/module:module_static",
"//xplat/executorch/extension/runner_util:managed_tensor_static",
],
)

fb_android_cxx_library(
name = "executorch_jni_full",
srcs = ["jni_layer.cpp"],
headers = ["jni_layer_constants.h"],
allow_jni_merging = False,
compiler_flags = [
"-frtti",
"-fexceptions",
],
soname = "libexecutorch.$(ext)",
visibility = ["PUBLIC"],
deps = [
":generated_op_lib_optimized_static",
"//fbandroid/libraries/fbjni:fbjni",
"//fbandroid/native/fb:fb",
"//third-party/glog:glog",
"//xplat/executorch/backends/xnnpack:xnnpack_backend_static",
"//xplat/executorch/extension/module:module_static",
"//xplat/executorch/extension/runner_util:managed_tensor_static",
],
)

fb_android_cxx_library(
name = "executorch_llama_jni",
srcs = ["jni_layer_llama.cpp"],
allow_jni_merging = False,
compiler_flags = [
"-frtti",
"-fexceptions",
"-Wno-format",
],
soname = "libexecutorch_llama_jni.$(ext)",
visibility = ["PUBLIC"],
deps = [
"//fbandroid/libraries/fbjni:fbjni",
"//fbandroid/native/fb:fb",
"//third-party/glog:glog",
"//xplat/executorch/examples/models/llama2/runner:runner_static",
"//xplat/executorch/examples/models/llava/runner:runner_static",
"//xplat/executorch/extension/threadpool:cpuinfo_utils_static",
"//xplat/executorch/extension/threadpool:threadpool_static",
],
)

0 comments on commit 5156615

Please sign in to comment.