Skip to content

Commit 246b509

Browse files
committed
Use old API
1 parent 42940bd commit 246b509

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import android.util.Log;
1212
import com.facebook.soloader.nativeloader.NativeLoader;
1313
import com.facebook.soloader.nativeloader.SystemDelegate;
14-
import java.nio.file.Files;
15-
import java.nio.file.Paths;
14+
import java.io.File;
1615
import java.util.concurrent.locks.Lock;
1716
import java.util.concurrent.locks.ReentrantLock;
1817
import org.pytorch.executorch.annotations.Experimental;
@@ -54,7 +53,7 @@ public static Module load(final String modelPath, int loadMode) {
5453
if (!NativeLoader.isInitialized()) {
5554
NativeLoader.init(new SystemDelegate());
5655
}
57-
if (!Files.isReadable(Paths.get(modelPath))) {
56+
if (!new File(modelPath).canRead()) {
5857
throw new RuntimeException("Cannot load model path " + modelPath);
5958
}
6059
return new Module(new NativePeer(modelPath, loadMode));

extension/android/executorch_android/src/main/java/org/pytorch/executorch/extension/llm/LlmModule.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import com.facebook.jni.annotations.DoNotStrip;
1313
import com.facebook.soloader.nativeloader.NativeLoader;
1414
import com.facebook.soloader.nativeloader.SystemDelegate;
15-
import java.nio.file.Files;
16-
import java.nio.file.Paths;
15+
import java.io.File;
1716
import org.pytorch.executorch.annotations.Experimental;
1817

1918
/**
@@ -49,10 +48,10 @@ private static native HybridData initHybrid(
4948
*/
5049
public LlmModule(
5150
int modelType, String modulePath, String tokenizerPath, float temperature, String dataPath) {
52-
if (!Files.isReadable(Paths.get(modulePath))) {
51+
if (!new File(modulePath).canRead()) {
5352
throw new RuntimeException("Cannot load model path " + modulePath);
5453
}
55-
if (!Files.isReadable(Paths.get(tokenizerPath))) {
54+
if (!new File(tokenizerPath).canRead()) {
5655
throw new RuntimeException("Cannot load tokenizer path " + tokenizerPath);
5756
}
5857
mHybridData = initHybrid(modelType, modulePath, tokenizerPath, temperature, dataPath);

0 commit comments

Comments
 (0)