Skip to content

Commit d12a854

Browse files
GregoryComerfacebook-github-bot
authored andcommitted
Restore explicit so load in Module.java (#11385)
Summary: This is a partial revert of #11058. We are seeing issues with JNI loading on Meta apps. My best guess is that the call to ExecuTorchRuntime is getting optimized out in Module.java, since the result is not used. I'm re-adding the explicit load back until we get that figured out. Reviewed By: bugraoral, larryliu0820 Differential Revision: D75994546
1 parent 3550824 commit d12a854

File tree

1 file changed

+10
-0
lines changed
  • extension/android/executorch_android/src/main/java/org/pytorch/executorch

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import android.util.Log;
1212
import com.facebook.jni.HybridData;
1313
import com.facebook.jni.annotations.DoNotStrip;
14+
import com.facebook.soloader.nativeloader.NativeLoader;
15+
import com.facebook.soloader.nativeloader.SystemDelegate;
1416
import java.io.File;
1517
import java.util.HashMap;
1618
import java.util.Map;
@@ -26,6 +28,14 @@
2628
@Experimental
2729
public class Module {
2830

31+
static {
32+
if (!NativeLoader.isInitialized()) {
33+
NativeLoader.init(new SystemDelegate());
34+
}
35+
// Loads libexecutorch.so from jniLibs
36+
NativeLoader.loadLibrary("executorch");
37+
}
38+
2939
/** Load mode for the module. Load the whole file as a buffer. */
3040
public static final int LOAD_MODE_FILE = 0;
3141

0 commit comments

Comments
 (0)