Skip to content

Commit ca889fb

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Minibench use model_dir instead (#5250)
Summary: We specify a model dir, not model path. It's easier to update test spec Pull Request resolved: #5250 Reviewed By: huydhn Differential Revision: D62473641 Pulled By: kirklandsign fbshipit-source-id: 40864831de9960fe29b101683ef7182e2f56fe7b
1 parent cba5bee commit ca889fb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

extension/android/benchmark/app/src/main/java/org/pytorch/minibench/BenchmarkActivity.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,30 @@
1111
import android.app.Activity;
1212
import android.content.Intent;
1313
import android.os.Bundle;
14+
import java.io.File;
1415
import java.io.FileWriter;
1516
import java.io.IOException;
17+
import java.util.Arrays;
1618
import org.pytorch.executorch.Module;
1719

1820
public class BenchmarkActivity extends Activity {
1921
@Override
2022
protected void onCreate(Bundle savedInstanceState) {
2123
super.onCreate(savedInstanceState);
2224
Intent intent = getIntent();
23-
String modelPath = intent.getStringExtra("model_path");
25+
File modelDir = new File(intent.getStringExtra("model_dir"));
26+
File model =
27+
Arrays.stream(modelDir.listFiles())
28+
.filter(file -> file.getName().endsWith(".pte"))
29+
.findFirst()
30+
.get();
31+
2432
int numIter = intent.getIntExtra("num_iter", 10);
2533

2634
// TODO: Format the string with a parsable format
2735
StringBuilder resultText = new StringBuilder();
2836

29-
Module module = Module.load(modelPath);
37+
Module module = Module.load(model.getPath());
3038
for (int i = 0; i < numIter; i++) {
3139
long start = System.currentTimeMillis();
3240
module.forward();

0 commit comments

Comments
 (0)