File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
src/main/java/org/pytorch/executorch Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -354,12 +354,12 @@ class ExecuTorchJni : public facebook::jni::HybridClass<ExecuTorchJni> {
354
354
}
355
355
356
356
jint forward_ones () {
357
+ auto && load_result = module_->load_method (" forward" );
357
358
auto && buf = prepare_input_tensors (*(module_->methods_ [" forward" ].method ));
358
- auto && result = module_->forward ();
359
- return (jint) result. error () ;
359
+ auto && result = module_->methods_ [ " forward" ]. method -> execute ();
360
+ return (jint) result;
360
361
}
361
362
362
-
363
363
static void registerNatives () {
364
364
registerHybrid ({
365
365
makeNativeMethod (" initHybrid" , ExecuTorchJni::initHybrid),
Original file line number Diff line number Diff line change @@ -79,6 +79,12 @@ public static Module load(final String modelPath) {
79
79
* @return return value from the 'forward' method.
80
80
*/
81
81
public EValue [] forward (EValue ... inputs ) {
82
+ if (inputs .length == 0 ) {
83
+ // forward default args (ones)
84
+ mNativePeer .forwardOnes ();
85
+ // discard the return value
86
+ return null ;
87
+ }
82
88
return mNativePeer .forward (inputs );
83
89
}
84
90
You can’t perform that action at this time.
0 commit comments