Skip to content

Add a single-.so Vulkan+XNNPACK executorch JNI target - #22398

Open
youxie wants to merge 1 commit into
pytorch:mainfrom
youxie:export-D118236328
Open

Add a single-.so Vulkan+XNNPACK executorch JNI target#22398
youxie wants to merge 1 commit into
pytorch:mainfrom
youxie:export-D118236328

Conversation

@youxie

@youxie youxie commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary:
Lets the executorch Android JNI sources be compiled from a Buck package other
than their own.

log.cpp and the JNI headers were not exported, and jni_helper.cpp and
log.cpp included their headers by relative path (#include "log.h"). That
form only resolves while the file is compiled inside
extension/android/jni; the moment another target picks the .cpp up as an
exported source, the include fails. This exports the missing files and
switches both includes to the full <executorch/extension/android/jni/...>
path used everywhere else in the tree.

Motivating case: building one libexecutorch.so that bundles the JNI bridge,
the runtime, and both the Vulkan and XNNPACK backends. Android's linker only
runs static initializers for libraries reached through an explicit
System.loadLibrary, so splitting the backends across several .so files
leaves their REGISTER_BACKEND globals unexecuted and the backends invisible
at runtime. Composing everything into a single .so requires reusing these
JNI sources from another package, which is what the include change enables.

No behavior change to any existing target.

Differential Revision: D118236328

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

Summary:
Lets the executorch Android JNI sources be compiled from a Buck package other
than their own.

`log.cpp` and the JNI headers were not exported, and `jni_helper.cpp` and
`log.cpp` included their headers by relative path (`#include "log.h"`). That
form only resolves while the file is compiled inside
`extension/android/jni`; the moment another target picks the `.cpp` up as an
exported source, the include fails. This exports the missing files and
switches both includes to the full `<executorch/extension/android/jni/...>`
path used everywhere else in the tree.

Motivating case: building one `libexecutorch.so` that bundles the JNI bridge,
the runtime, and both the Vulkan and XNNPACK backends. Android's linker only
runs static initializers for libraries reached through an explicit
`System.loadLibrary`, so splitting the backends across several `.so` files
leaves their `REGISTER_BACKEND` globals unexecuted and the backends invisible
at runtime. Composing everything into a single `.so` requires reusing these
JNI sources from another package, which is what the include change enables.

No behavior change to any existing target.

Differential Revision: D118236328
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Sep 1, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22398

Note: Links to docs will display an error until the docs builds have been completed.

❌ 5 New Failures, 1 Unrelated Failure

As of commit d48ddea with merge base fdae101 (image):

NEW FAILURES - The following jobs have failed:

  • Cadence Build & Test / hifi-build / hifi4 (gh)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.
  • Cadence Build & Test / vision-build / vision (gh)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.
  • pull / unittest / linux / linux-job (gh)
    pytorch_tokenizers
  • pull / unittest-buck / linux / linux-job (gh)
    pytorch_tokenizers
  • pull / unittest-editable / linux / linux-job (gh)
    pytorch_tokenizers

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 1, 2026
@meta-codesync

meta-codesync Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@youxie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D118236328.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant