Skip to content

Commit

Permalink
Minibench use model_dir instead (#5250)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kirklandsign authored and facebook-github-bot committed Sep 11, 2024
1 parent cba5bee commit ca889fb
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 ca889fb

Please sign in to comment.