File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
extension/android/benchmark
app/src/main/java/org/pytorch/minibench Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ phases:
80
80
--es "model_dir" "/data/local/tmp/llama" \
81
81
--es "tokenizer_path" "/data/local/tmp/llama/tokenizer.bin"
82
82
83
+ - echo "Run generic benchmark"
84
+ - |
85
+ adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.BenchmarkActivity \
86
+ --es "model_dir" "/data/local/tmp/llama"
87
+
88
+
83
89
post_test :
84
90
commands :
85
91
- echo "Gather LLM benchmark results"
Original file line number Diff line number Diff line change 11
11
import android .app .Activity ;
12
12
import android .content .Intent ;
13
13
import android .os .Bundle ;
14
+ import java .io .File ;
14
15
import java .io .FileWriter ;
15
16
import java .io .IOException ;
17
+ import java .util .Arrays ;
16
18
import org .pytorch .executorch .Module ;
17
19
18
20
public class BenchmarkActivity extends Activity {
19
21
@ Override
20
22
protected void onCreate (Bundle savedInstanceState ) {
21
23
super .onCreate (savedInstanceState );
22
24
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
+
24
32
int numIter = intent .getIntExtra ("num_iter" , 10 );
25
33
26
34
// TODO: Format the string with a parsable format
27
35
StringBuilder resultText = new StringBuilder ();
28
36
29
- Module module = Module .load (modelPath );
37
+ Module module = Module .load (model . getPath () );
30
38
for (int i = 0 ; i < numIter ; i ++) {
31
39
long start = System .currentTimeMillis ();
32
40
module .forward ();
You can’t perform that action at this time.
0 commit comments