Skip to content

Commit f7a8888

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

File tree

1 file changed

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

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,20 @@ 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 must not be called while a previous inference is in progress.
71+
* Additionally, if method 'forward' requires inputs but no inputs are given, the
72+
* 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 must not be called while a previous inference is in progress.
8083
*
8184
* @param methodName name of the ExecuTorch method to run.
8285
* @param inputs arguments that will be passed to ExecuTorch method.

0 commit comments

Comments
 (0)