Skip to content

Commit a6b213b

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Android cleanup java api (#6022)
Summary: Pull Request resolved: #6022 Reviewed By: shoumikhin Differential Revision: D64073604 Pulled By: kirklandsign fbshipit-source-id: 2bbe0792b7094ef7438b602c958adddd9b55a6d1
1 parent 72b3bb3 commit a6b213b

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

extension/android/jni/jni_layer.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,11 @@ class ExecuTorchJni : public facebook::jni::HybridClass<ExecuTorchJni> {
243243
static facebook::jni::local_ref<jhybriddata> initHybrid(
244244
facebook::jni::alias_ref<jclass>,
245245
facebook::jni::alias_ref<jstring> modelPath,
246-
facebook::jni::alias_ref<
247-
facebook::jni::JMap<facebook::jni::JString, facebook::jni::JString>>
248-
extraFiles,
249246
jint loadMode) {
250-
return makeCxxInstance(modelPath, extraFiles, loadMode);
247+
return makeCxxInstance(modelPath, loadMode);
251248
}
252249

253-
ExecuTorchJni(
254-
facebook::jni::alias_ref<jstring> modelPath,
255-
facebook::jni::alias_ref<
256-
facebook::jni::JMap<facebook::jni::JString, facebook::jni::JString>>
257-
extraFiles,
258-
jint loadMode) {
250+
ExecuTorchJni(facebook::jni::alias_ref<jstring> modelPath, jint loadMode) {
259251
Module::LoadMode load_mode = Module::LoadMode::Mmap;
260252
if (loadMode == 0) {
261253
load_mode = Module::LoadMode::File;

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import com.facebook.soloader.nativeloader.NativeLoader;
1212
import com.facebook.soloader.nativeloader.SystemDelegate;
13-
import java.util.Map;
1413
import org.pytorch.executorch.annotations.Experimental;
1514

1615
/**
@@ -36,32 +35,18 @@ public class Module {
3635
/** Reference to the NativePeer object of this module. */
3736
private NativePeer mNativePeer;
3837

39-
/**
40-
* Loads a serialized ExecuTorch module from the specified path on the disk. Uses default load
41-
* FILE.
42-
*
43-
* @param modelPath path to file that contains the serialized ExecuTorch module.
44-
* @param extraFiles map with extra files names as keys, content of them will be loaded to values.
45-
* @return new {@link org.pytorch.executorch.Module} object which owns the model module.
46-
*/
47-
public static Module load(final String modelPath, final Map<String, String> extraFiles) {
48-
return load(modelPath, extraFiles, LOAD_MODE_FILE);
49-
}
50-
5138
/**
5239
* Loads a serialized ExecuTorch module from the specified path on the disk.
5340
*
5441
* @param modelPath path to file that contains the serialized ExecuTorch module.
55-
* @param extraFiles map with extra files names as keys, content of them will be loaded to values.
5642
* @param loadMode load mode for the module. See constants in {@link Module}.
5743
* @return new {@link org.pytorch.executorch.Module} object which owns the model module.
5844
*/
59-
public static Module load(
60-
final String modelPath, final Map<String, String> extraFiles, int loadMode) {
45+
public static Module load(final String modelPath, int loadMode) {
6146
if (!NativeLoader.isInitialized()) {
6247
NativeLoader.init(new SystemDelegate());
6348
}
64-
return new Module(new NativePeer(modelPath, extraFiles, loadMode));
49+
return new Module(new NativePeer(modelPath, loadMode));
6550
}
6651

6752
/**
@@ -71,7 +56,7 @@ public static Module load(
7156
* @return new {@link org.pytorch.executorch.Module} object which owns the model module.
7257
*/
7358
public static Module load(final String modelPath) {
74-
return load(modelPath, null);
59+
return load(modelPath, LOAD_MODE_FILE);
7560
}
7661

7762
Module(NativePeer nativePeer) {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.facebook.jni.HybridData;
1212
import com.facebook.jni.annotations.DoNotStrip;
1313
import com.facebook.soloader.nativeloader.NativeLoader;
14-
import java.util.Map;
1514
import org.pytorch.executorch.annotations.Experimental;
1615

1716
/**
@@ -29,11 +28,10 @@ class NativePeer {
2928
private final HybridData mHybridData;
3029

3130
@DoNotStrip
32-
private static native HybridData initHybrid(
33-
String moduleAbsolutePath, Map<String, String> extraFiles, int loadMode);
31+
private static native HybridData initHybrid(String moduleAbsolutePath, int loadMode);
3432

35-
NativePeer(String moduleAbsolutePath, Map<String, String> extraFiles, int loadMode) {
36-
mHybridData = initHybrid(moduleAbsolutePath, extraFiles, loadMode);
33+
NativePeer(String moduleAbsolutePath, int loadMode) {
34+
mHybridData = initHybrid(moduleAbsolutePath, loadMode);
3735
}
3836

3937
/** Clean up the native resources associated with this instance */

0 commit comments

Comments
 (0)