Skip to content

Android input and output tag JNI #11057

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Conversation

kirklandsign
Copy link
Contributor

Summary

Add JNI helper to get tags. Add API later.

Test plan

CI

Copy link

pytorch-bot bot commented May 21, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 06f8e7b with merge base df5e7df (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 May 21, 2025
@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@kirklandsign kirklandsign requested a review from Copilot May 21, 2025 23:00
@kirklandsign kirklandsign added the release notes: api Changes to public facing apis (any interfaces, pybinded runtime methods, etc.) label May 21, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces new JNI helper methods to retrieve input and output tags for Android, and updates the corresponding Java API and tests.

  • Added getInputTags and getOutputTags methods in the JNI layer.
  • Updated the Java Module and MethodMetadata classes to store and use the new tag information.
  • Adjusted tests to verify the new behavior.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
extension/android/jni/jni_layer.cpp Added native methods getInputTags and getOutputTags and registered them; minor variable renaming adjustments.
extension/android/executorch_android/src/main/java/org/pytorch/executorch/Module.java Updated to declare native methods for input and output tags and populate MethodMetadata with them.
extension/android/executorch_android/src/main/java/org/pytorch/executorch/MethodMetadata.java Extended the class to include inputTags and outputTags with corresponding getters and setters.
extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch/ModuleInstrumentationTest.kt Added assertions to check the returned input and output tags.
extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch/ModuleE2ETest.kt Updated expected backend array formatting.

facebook::jni::local_ref<facebook::jni::JArrayInt> ret =
facebook::jni::JArrayInt::newArray(num_inputs);

int i = 0;
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outer declaration of the variable 'i' is redundant as the for-loop declares its own 'i'. Remove the unnecessary declaration to improve clarity.

Suggested change
int i = 0;

Copilot uses AI. Check for mistakes.

facebook::jni::JArrayInt::newArray(num_outputs);

int i = 0;
for (int i = 0; i < num_outputs; i++) {
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'i' is declared before the for-loop and then re-declared in the loop, which shadows the outer variable. Removing the redundant declaration will prevent potential confusion.

Suggested change
for (int i = 0; i < num_outputs; i++) {
for (i = 0; i < num_outputs; i++) {

Copilot uses AI. Check for mistakes.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

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. release notes: api Changes to public facing apis (any interfaces, pybinded runtime methods, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants