@@ -10,18 +10,21 @@ phases:
1010 commands :
1111 # Prepare the model and the tokenizer
1212 - adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /sdcard/"
13- - adb -s $DEVICEFARM_DEVICE_UDID shell "mkdir -p /data/local/tmp/llama/"
14- - adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/*.bin /data/local/tmp/llama/"
15- - adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/*.pte /data/local/tmp/llama/"
16- - adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/llama/*.bin"
17- - adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/llama/*.pte"
18- - adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /data/local/tmp/llama/"
13+ - adb -s $DEVICEFARM_DEVICE_UDID shell "mkdir -p /data/local/tmp/minibench/"
14+ - adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/*.bin /data/local/tmp/minibench/"
15+ - adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/*.pte /data/local/tmp/minibench/"
16+ - adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/minibench/*.bin"
17+ - adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/minibench/*.pte"
18+ - adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /data/local/tmp/minibench/"
19+ - adb -s $DEVICEFARM_DEVICE_UDID shell "run-as org.pytorch.minibench rm -rf files"
1920
2021 test :
2122 commands :
2223 # By default, the following ADB command is used by Device Farm to run your Instrumentation test.
2324 # Please refer to Android's documentation for more options on running instrumentation tests with adb:
2425 # https://developer.android.com/studio/test/command-line#run-tests-with-adb
26+
27+ # Run the Instrumentation test for sanity check
2528 - echo "Starting the Instrumentation test"
2629 - |
2730 adb -s $DEVICEFARM_DEVICE_UDID shell "am instrument -r -w --no-window-animation \
@@ -67,17 +70,33 @@ phases:
6770 fi;
6871
6972 # Run the new generic benchmark activity https://developer.android.com/tools/adb#am
70- - echo "Run LLM benchmark"
73+ - echo "Determine model type"
74+ - |
75+ BIN_FOUND="$(adb -s $DEVICEFARM_DEVICE_UDID shell find /data/local/tmp/minibench/ -name '*.bin')"
76+ if [ -z "$BIN_FOUND" ]; then
77+ echo "No tokenizer files found in /data/local/tmp/minibench/"
78+ else
79+ echo "tokenizer files found in /data/local/tmp/minibench/"
80+ fi
81+
82+ - echo "Run benchmark"
7183 - |
72- adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.LlmBenchmarkActivity \
73- --es "model_dir" "/data/local/tmp/llama" \
74- --es "tokenizer_path" "/data/local/tmp/llama/tokenizer.bin"
84+ adb -s $DEVICEFARM_DEVICE_UDID shell am force-stop org.pytorch.minibench
85+ if [ -z "$BIN_FOUND" ]; then
86+ adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.BenchmarkActivity \
87+ --es "model_dir" "/data/local/tmp/minibench"
88+ else
89+ adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.LlmBenchmarkActivity \
90+ --es "model_dir" "/data/local/tmp/minibench" \
91+ --es "tokenizer_path" "/data/local/tmp/minibench/tokenizer.bin"
92+ fi
93+
7594
7695 post_test :
7796 commands :
78- - echo "Gather LLM benchmark results"
97+ - echo "Gather benchmark results"
7998 - |
80- BENCHMARK_RESULTS=""
99+ BENCHMARK_RESULTS=$(adb -s $DEVICEFARM_DEVICE_UDID shell run-as org.pytorch.minibench cat files/benchmark_results.json)
81100 ATTEMPT=0
82101 MAX_ATTEMPT=10
83102 while [ -z "${BENCHMARK_RESULTS}" ] && [ $ATTEMPT -lt $MAX_ATTEMPT ]; do
0 commit comments