Skip to content

Commit 1d46d72

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Android Java introduce Experimental API annotation (#5303)
Summary: Pull Request resolved: #5303 Reviewed By: shoumikhin Differential Revision: D62557706 Pulled By: kirklandsign fbshipit-source-id: b2d54cc2c4bf480f862aa1936dcd4075ab7b29c0
1 parent 905df29 commit 1d46d72

File tree

9 files changed

+35
-0
lines changed

9 files changed

+35
-0
lines changed

extension/android/BUCK

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ fb_android_library(
1010
"src/main/java/org/pytorch/executorch/Module.java",
1111
"src/main/java/org/pytorch/executorch/NativePeer.java",
1212
"src/main/java/org/pytorch/executorch/Tensor.java",
13+
"src/main/java/org/pytorch/executorch/annotations/Experimental.java",
1314
],
1415
autoglob = False,
1516
language = "JAVA",
@@ -24,6 +25,7 @@ fb_android_library(
2425
srcs = [
2526
"src/main/java/org/pytorch/executorch/LlamaCallback.java",
2627
"src/main/java/org/pytorch/executorch/LlamaModule.java",
28+
"src/main/java/org/pytorch/executorch/annotations/Experimental.java",
2729
],
2830
autoglob = False,
2931
language = "JAVA",

extension/android/src/main/java/org/pytorch/executorch/DType.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
package org.pytorch.executorch;
1010

11+
import org.pytorch.executorch.annotations.Experimental;
12+
1113
/**
1214
* Codes representing tensor data types.
1315
*
1416
* <p>Warning: These APIs are experimental and subject to change without notice
1517
*/
18+
@Experimental
1619
public enum DType {
1720
// NOTE: "jniCode" must be kept in sync with scalar_type.h.
1821
// NOTE: Never serialize "jniCode", because it can change between releases.

extension/android/src/main/java/org/pytorch/executorch/EValue.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.facebook.jni.annotations.DoNotStrip;
1212
import java.util.Locale;
1313
import java.util.Optional;
14+
import org.pytorch.executorch.annotations.Experimental;
1415

1516
/**
1617
* Java representation of an ExecuTorch value, which is implemented as tagged union that can be one
@@ -30,6 +31,7 @@
3031
*
3132
* <p>Warning: These APIs are experimental and subject to change without notice
3233
*/
34+
@Experimental
3335
@DoNotStrip
3436
public class EValue {
3537
private static final int TYPE_CODE_NONE = 0;

extension/android/src/main/java/org/pytorch/executorch/LlamaCallback.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
package org.pytorch.executorch;
1010

1111
import com.facebook.jni.annotations.DoNotStrip;
12+
import org.pytorch.executorch.annotations.Experimental;
1213

1314
/**
1415
* Callback interface for Llama model. Users can implement this interface to receive the generated
1516
* tokens and statistics.
1617
*
1718
* <p>Warning: These APIs are experimental and subject to change without notice
1819
*/
20+
@Experimental
1921
public interface LlamaCallback {
2022
/**
2123
* Called when a new result is available from JNI. Users will keep getting onResult() invocations

extension/android/src/main/java/org/pytorch/executorch/LlamaModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
import com.facebook.jni.annotations.DoNotStrip;
1313
import com.facebook.soloader.nativeloader.NativeLoader;
1414
import com.facebook.soloader.nativeloader.SystemDelegate;
15+
import org.pytorch.executorch.annotations.Experimental;
1516

1617
/**
1718
* LlamaModule is a wrapper around the Executorch Llama model. It provides a simple interface to
1819
* generate text from the model.
1920
*
2021
* <p>Warning: These APIs are experimental and subject to change without notice
2122
*/
23+
@Experimental
2224
public class LlamaModule {
2325

2426
public static final int MODEL_TYPE_TEXT = 1;

extension/android/src/main/java/org/pytorch/executorch/Module.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import com.facebook.soloader.nativeloader.NativeLoader;
1212
import com.facebook.soloader.nativeloader.SystemDelegate;
1313
import java.util.Map;
14+
import org.pytorch.executorch.annotations.Experimental;
1415

1516
/**
1617
* Java wrapper for ExecuTorch Module.
1718
*
1819
* <p>Warning: These APIs are experimental and subject to change without notice
1920
*/
21+
@Experimental
2022
public class Module {
2123

2224
/** Load mode for the module. Load the whole file as a buffer. */

extension/android/src/main/java/org/pytorch/executorch/NativePeer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
import com.facebook.jni.annotations.DoNotStrip;
1313
import com.facebook.soloader.nativeloader.NativeLoader;
1414
import java.util.Map;
15+
import org.pytorch.executorch.annotations.Experimental;
1516

1617
/**
1718
* Interface for the native peer object for entry points to the Module
1819
*
1920
* <p>Warning: These APIs are experimental and subject to change without notice
2021
*/
22+
@Experimental
2123
class NativePeer {
2224
static {
2325
// Loads libexecutorch.so from jniLibs

extension/android/src/main/java/org/pytorch/executorch/Tensor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.nio.LongBuffer;
2020
import java.util.Arrays;
2121
import java.util.Locale;
22+
import org.pytorch.executorch.annotations.Experimental;
2223

2324
/**
2425
* Representation of an ExecuTorch Tensor. Behavior is similar to PyTorch's tensor objects.
@@ -39,6 +40,7 @@
3940
*
4041
* <p>Warning: These APIs are experimental and subject to change without notice
4142
*/
43+
@Experimental
4244
public abstract class Tensor {
4345
private static final String ERROR_MSG_DATA_BUFFER_NOT_NULL = "Data buffer must be not null";
4446
private static final String ERROR_MSG_DATA_ARRAY_NOT_NULL = "Data array must be not null";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
package org.pytorch.executorch.annotations;
10+
11+
/**
12+
* This annotation indicates that an API is experimental and may change or be removed at any time.
13+
* It does not provide any guarantees for API stability or backward-compatibility.
14+
*
15+
* <p>This status is not permanent, and APIs marked with this annotation will need to be either made
16+
* more robust or removed in the future.
17+
*/
18+
public @interface Experimental {}

0 commit comments

Comments
 (0)