Skip to content

Commit

Permalink
[Android] Minibench use model_dir instead
Browse files Browse the repository at this point in the history
We specify a model dir, not model path. It's easier to update test spec
  • Loading branch information
kirklandsign committed Sep 10, 2024
1 parent cac2c05 commit 426f203
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,30 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import org.pytorch.executorch.Module;

public class BenchmarkActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String modelPath = intent.getStringExtra("model_path");
File modelDir = new File(intent.getStringExtra("model_dir"));
File model =
Arrays.stream(modelDir.listFiles())
.filter(file -> file.getName().endsWith(".pte"))
.findFirst()
.get();

int numIter = intent.getIntExtra("num_iter", 10);

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

Module module = Module.load(modelPath);
Module module = Module.load(model.getPath());
for (int i = 0; i < numIter; i++) {
long start = System.currentTimeMillis();
module.forward();
Expand Down

0 comments on commit 426f203

Please sign in to comment.