Skip to content

Commit 9e83e9f

Browse files
GregoryComerfacebook-github-bot
authored andcommitted
Update JNI binding layer comments to indicate that forward/execute is not thread-safe
Summary: Update doc comments on forward and execute to document that these functions are not thread-safe. Differential Revision: D66144668
1 parent 86cb5d7 commit 9e83e9f

File tree

1 file changed

+8
-4
lines changed
  • extension/android/src/main/java/org/pytorch/executorch

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,21 @@ public static Module load(final String modelPath) {
6666
/**
6767
* Runs the 'forward' method of this module with the specified arguments.
6868
*
69-
* @param inputs arguments for the ExecuTorch module's 'forward' method. Note: if method 'forward'
70-
* requires inputs but no inputs are given, the function will not error out, but run 'forward'
71-
* with sample inputs.
69+
* @param inputs arguments for the ExecuTorch module's 'forward' method. This function is
70+
* not thread safe and thus must not be called again while a previous inference is in
71+
* progress. Additionally, if method 'forward' requires inputs but no inputs are given,
72+
* the function will not error out, but run 'forward' with sample inputs.
73+
*
7274
* @return return value from the 'forward' method.
7375
*/
7476
public EValue[] forward(EValue... inputs) {
7577
return mNativePeer.forward(inputs);
7678
}
7779

7880
/**
79-
* Runs the specified method of this module with the specified arguments.
81+
* Runs the specified method of this module with the specified arguments. This function is
82+
* not thread safe and thus must not be called again until while a previous inference is
83+
* in progress.
8084
*
8185
* @param methodName name of the ExecuTorch method to run.
8286
* @param inputs arguments that will be passed to ExecuTorch method.

0 commit comments

Comments
 (0)