Przemyslaw Szczepaniak | 9429af4 | 2018-09-28 17:07:24 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Build benchmark app and run it, mimicking a user-initiated run |
| 4 | # |
| 5 | # Output is logged to a temporary folder and summarized in txt and JSON formats. |
Stefano Galarraga | 4edc2ea | 2020-03-02 15:38:02 +0000 | [diff] [blame] | 6 | # parallel-inference-stress tests produce no output except for the success or failure notification, |
| 7 | # which is not logged. |
Slava Shklyaev | e8198d4 | 2019-05-15 16:43:46 +0100 | [diff] [blame] | 8 | |
Stefano Galarraga | 013f4b3 | 2020-08-11 08:56:31 +0100 | [diff] [blame] | 9 | if [[ "$OSTYPE" == "darwin"* ]]; then |
Stefano Galarraga | fdbb44e | 2021-10-04 17:20:17 +0100 | [diff] [blame] | 10 | OPTS="$(getopt f:rbsm:x -- "$*")" |
Stefano Galarraga | 013f4b3 | 2020-08-11 08:56:31 +0100 | [diff] [blame] | 11 | else |
Stefano Galarraga | fdbb44e | 2021-10-04 17:20:17 +0100 | [diff] [blame] | 12 | OPTS="$(getopt -o f:rbsm:x -l filter-driver:,include-nnapi-reference,nnapi-reference-only,skip-build,use-nnapi-sl,filter-model,extract-nnapi-sl -- "$@")" |
Stefano Galarraga | 013f4b3 | 2020-08-11 08:56:31 +0100 | [diff] [blame] | 13 | fi |
Stefano Galarraga | 06ec72b | 2020-05-29 10:47:31 +0100 | [diff] [blame] | 14 | |
| 15 | if [ $? -ne 0 ]; then |
Stefano Galarraga | 013f4b3 | 2020-08-11 08:56:31 +0100 | [diff] [blame] | 16 | echo "Invalid arguments, accepted options are" |
| 17 | if [[ "$OSTYPE" == "darwin"* ]]; then |
| 18 | echo " -f <regex> : to run crash tests only on the drivers (ignoring nnapi-reference) matching the specified regular expression" |
| 19 | echo " -r : to include nnapi-reference in target drivers" |
| 20 | echo " -b : skip build and installation of tests" |
Stefano Galarraga | fdbb44e | 2021-10-04 17:20:17 +0100 | [diff] [blame] | 21 | echo " -s : use NNAPI Support Library drivers (embedded in the benchmark APK unless -x is specified)" |
| 22 | echo " -x : extract NNAPI Support Library drivers from the APK" |
Stefano Galarraga | 3860feb | 2021-09-22 19:13:22 +0100 | [diff] [blame] | 23 | echo " -m <regex> : to filter the models used in the tests" |
Stefano Galarraga | 013f4b3 | 2020-08-11 08:56:31 +0100 | [diff] [blame] | 24 | else |
Stefano Galarraga | 06ec72b | 2020-05-29 10:47:31 +0100 | [diff] [blame] | 25 | echo " -f <regex> | --filter-driver <regex> : to run crash tests only on the drivers (ignoring nnapi-reference) matching the specified regular expression" |
| 26 | echo " -r | --include-nnapi-reference : to include nnapi-reference in target drivers" |
| 27 | echo " --nnapi-reference-only : to run tests only vs nnapi-reference" |
Stefano Galarraga | 2583479 | 2020-06-11 19:02:03 +0100 | [diff] [blame] | 28 | echo " -b | --skip-build : skip build and installation of tests" |
Stefano Galarraga | fdbb44e | 2021-10-04 17:20:17 +0100 | [diff] [blame] | 29 | echo " -s | --use-nnapi-sl : use NNAPI Support Library drivers (embedded in the benchmark APK unless -x is specified)" |
| 30 | echo " -x | --extract-nnapi-sl : extract NNAPI Support Library drivers from the APK" |
Stefano Galarraga | 3860feb | 2021-09-22 19:13:22 +0100 | [diff] [blame] | 31 | echo " -m <regex> : to filter the models used in the tests" |
Stefano Galarraga | 013f4b3 | 2020-08-11 08:56:31 +0100 | [diff] [blame] | 32 | fi |
| 33 | exit |
Stefano Galarraga | 06ec72b | 2020-05-29 10:47:31 +0100 | [diff] [blame] | 34 | fi |
| 35 | |
| 36 | eval set -- "$OPTS" |
| 37 | |
| 38 | DRIVER_FILTER_OPT="" |
| 39 | INCLUDE_NNAPI_REF_OPT="" |
Stefano Galarraga | 2583479 | 2020-06-11 19:02:03 +0100 | [diff] [blame] | 40 | BUILD_AND_INSTALL=true |
Stefano Galarraga | 57b6e4c | 2021-09-10 15:18:12 +0100 | [diff] [blame] | 41 | NNAPI_SL_FILTER_OPT="" |
Stefano Galarraga | 3860feb | 2021-09-22 19:13:22 +0100 | [diff] [blame] | 42 | MODEL_FILTER_OPT="" |
Stefano Galarraga | 06ec72b | 2020-05-29 10:47:31 +0100 | [diff] [blame] | 43 | while [ $# -gt 0 ] ; do |
| 44 | case "$1" in |
| 45 | -f|--filter-driver) |
| 46 | DRIVER_FILTER_OPT="-e nnCrashtestDeviceFilter $2" |
| 47 | shift 2 |
| 48 | ;; |
| 49 | -r|--include-nnapi-reference) |
| 50 | INCLUDE_NNAPI_REF_OPT="-e nnCrashtestIncludeNnapiReference true" |
| 51 | shift |
| 52 | ;; |
| 53 | --nnapi-reference-only) |
| 54 | DRIVER_FILTER_OPT="-e nnCrashtestDeviceFilter no-device" |
| 55 | INCLUDE_NNAPI_REF_OPT="-e nnCrashtestIncludeNnapiReference true" |
| 56 | shift |
| 57 | ;; |
Stefano Galarraga | 3860feb | 2021-09-22 19:13:22 +0100 | [diff] [blame] | 58 | -m|--filter-model) |
| 59 | MODEL_FILTER_OPT="-e nnBenchmarkModelFilter $2" |
| 60 | shift 2 |
| 61 | ;; |
Stefano Galarraga | 2583479 | 2020-06-11 19:02:03 +0100 | [diff] [blame] | 62 | -b|--skip-build) |
| 63 | BUILD_AND_INSTALL=false |
| 64 | shift |
| 65 | ;; |
Stefano Galarraga | 57b6e4c | 2021-09-10 15:18:12 +0100 | [diff] [blame] | 66 | -s|--use-nnapi-sl) |
Stefano Galarraga | fdbb44e | 2021-10-04 17:20:17 +0100 | [diff] [blame] | 67 | NNAPI_SL_FILTER_OPT+=" -e useNnApiSupportLibrary true" |
| 68 | shift |
| 69 | ;; |
| 70 | -x|--extract-nnapi-sl) |
| 71 | NNAPI_SL_FILTER_OPT+=" -e extractNnApiSupportLibrary true" |
| 72 | shift |
| 73 | |
| 74 | echo "Creating configuration file with list of libraries" |
| 75 | mkdir sl_prebuilt/assets |
| 76 | ls sl_prebuilt/ 2>/dev/null | grep '.so' >sl_prebuilt/assets/sl_prebuilt_filelist.txt |
Stefano Galarraga | 57b6e4c | 2021-09-10 15:18:12 +0100 | [diff] [blame] | 77 | ;; |
Stefano Galarraga | 06ec72b | 2020-05-29 10:47:31 +0100 | [diff] [blame] | 78 | --) |
| 79 | shift |
| 80 | break |
| 81 | ;; |
| 82 | *) |
| 83 | echo "Unsupported arg $1" |
| 84 | exit 1 |
| 85 | esac |
| 86 | done |
| 87 | |
Slava Shklyaev | 1927d05 | 2019-07-29 12:02:54 +0100 | [diff] [blame] | 88 | MODE="${1:-scoring}" |
Stefano Galarraga | f03d573 | 2020-06-08 19:18:24 +0100 | [diff] [blame] | 89 | INSTALL_NATIVE_TESTS=false |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 90 | CRASH_TEST_APP="NeuralNetworksApiCrashTest" |
Stefano Galarraga | 650bda5 | 2020-06-17 11:03:07 +0100 | [diff] [blame] | 91 | APP="NeuralNetworksApiBenchmark" |
Slava Shklyaev | 814f8a7 | 2019-06-20 16:34:51 +0100 | [diff] [blame] | 92 | case "$MODE" in |
| 93 | scoring) |
Slava Shklyaev | e8198d4 | 2019-05-15 16:43:46 +0100 | [diff] [blame] | 94 | CLASS=com.android.nn.benchmark.app.NNScoringTest |
| 95 | ;; |
Slava Shklyaev | 814f8a7 | 2019-06-20 16:34:51 +0100 | [diff] [blame] | 96 | inference-stress) |
| 97 | CLASS=com.android.nn.benchmark.app.NNInferenceStressTest |
| 98 | ;; |
| 99 | model-loading-stress) |
| 100 | CLASS=com.android.nn.benchmark.app.NNModelLoadingStressTest |
Slava Shklyaev | e8198d4 | 2019-05-15 16:43:46 +0100 | [diff] [blame] | 101 | ;; |
Stefano Galarraga | 4edc2ea | 2020-03-02 15:38:02 +0000 | [diff] [blame] | 102 | parallel-inference-stress) |
Stefano Galarraga | 650bda5 | 2020-06-17 11:03:07 +0100 | [diff] [blame] | 103 | CLASS=com.android.nn.crashtest.app.NNParallelCrashResistantInferenceTest |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 104 | APP="$CRASH_TEST_APP" |
Stefano Galarraga | 4edc2ea | 2020-03-02 15:38:02 +0000 | [diff] [blame] | 105 | ;; |
| 106 | parallel-inference-stress-in-process) |
Stefano Galarraga | 650bda5 | 2020-06-17 11:03:07 +0100 | [diff] [blame] | 107 | CLASS=com.android.nn.crashtest.app.NNParallelInProcessInferenceTest |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 108 | APP="$CRASH_TEST_APP" |
Stefano Galarraga | 4edc2ea | 2020-03-02 15:38:02 +0000 | [diff] [blame] | 109 | ;; |
Stefano Galarraga | 2a10d15 | 2020-04-24 08:32:55 +0100 | [diff] [blame] | 110 | client-early-termination-stress) |
Stefano Galarraga | 650bda5 | 2020-06-17 11:03:07 +0100 | [diff] [blame] | 111 | CLASS=com.android.nn.crashtest.app.NNClientEarlyTerminationTest |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 112 | APP="$CRASH_TEST_APP" |
Stefano Galarraga | 2a10d15 | 2020-04-24 08:32:55 +0100 | [diff] [blame] | 113 | ;; |
Stefano Galarraga | f03d573 | 2020-06-08 19:18:24 +0100 | [diff] [blame] | 114 | multi-process-inference-stress) |
Stefano Galarraga | 650bda5 | 2020-06-17 11:03:07 +0100 | [diff] [blame] | 115 | CLASS=com.android.nn.crashtest.app.NNMultipleProcessInferenceTest |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 116 | APP="$CRASH_TEST_APP" |
Stefano Galarraga | f03d573 | 2020-06-08 19:18:24 +0100 | [diff] [blame] | 117 | INSTALL_NATIVE_TESTS=true |
| 118 | ;; |
| 119 | multi-process-model-load-stress) |
Stefano Galarraga | 650bda5 | 2020-06-17 11:03:07 +0100 | [diff] [blame] | 120 | CLASS=com.android.nn.crashtest.app.NNMultipleProcessModelLoadTest |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 121 | APP="$CRASH_TEST_APP" |
Stefano Galarraga | f03d573 | 2020-06-08 19:18:24 +0100 | [diff] [blame] | 122 | INSTALL_NATIVE_TESTS=true |
| 123 | ;; |
Stefano Galarraga | 965e78e | 2020-05-12 17:11:54 +0100 | [diff] [blame] | 124 | memory-mapped-model-load-stress) |
Stefano Galarraga | 650bda5 | 2020-06-17 11:03:07 +0100 | [diff] [blame] | 125 | CLASS=com.android.nn.crashtest.app.NNMemoryMappedModelCompilationTest |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 126 | APP="$CRASH_TEST_APP" |
Stefano Galarraga | 965e78e | 2020-05-12 17:11:54 +0100 | [diff] [blame] | 127 | ;; |
Stefano Galarraga | 04f119a | 2020-05-13 19:19:32 +0100 | [diff] [blame] | 128 | model-load-random-stress) |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 129 | APP="$CRASH_TEST_APP" |
Stefano Galarraga | 04f119a | 2020-05-13 19:19:32 +0100 | [diff] [blame] | 130 | CLASS=com.android.nn.crashtest.app.NNRandomGraphLoadTest |
| 131 | ;; |
Stefano Galarraga | f19cd01 | 2020-06-09 18:52:17 +0100 | [diff] [blame] | 132 | inference-random-stress) |
| 133 | APP="$CRASH_TEST_APP" |
| 134 | CLASS=com.android.nn.crashtest.app.NNRandomGraphExecutionTest |
| 135 | ;; |
Stefano Galarraga | 3edb25c | 2020-06-16 18:27:35 +0100 | [diff] [blame] | 136 | performance-degradation-stress) |
| 137 | APP="$CRASH_TEST_APP" |
| 138 | CLASS=com.android.nn.crashtest.app.NNPerformanceDegradationTest |
| 139 | ;; |
Slava Shklyaev | e8198d4 | 2019-05-15 16:43:46 +0100 | [diff] [blame] | 140 | *) |
| 141 | echo "Unknown execution mode: $1" |
Stefano Galarraga | f03d573 | 2020-06-08 19:18:24 +0100 | [diff] [blame] | 142 | echo "Known modes: scoring (default), inference-stress, model-loading-stress, " \ |
| 143 | "parallel-inference-stress, parallel-inference-stress-in-process, " \ |
| 144 | "client-early-termination-stress, multi-process-inference-stress, " \ |
Stefano Galarraga | 04f119a | 2020-05-13 19:19:32 +0100 | [diff] [blame] | 145 | "multi-process-model-load-stress memory-mapped-model-load-stress, " \ |
Stefano Galarraga | 3edb25c | 2020-06-16 18:27:35 +0100 | [diff] [blame] | 146 | "model-load-random-stress, inference-random-stress, performance-degradation-stress" |
Slava Shklyaev | e8198d4 | 2019-05-15 16:43:46 +0100 | [diff] [blame] | 147 | exit 1 |
| 148 | ;; |
| 149 | esac |
Przemyslaw Szczepaniak | 9429af4 | 2018-09-28 17:07:24 +0100 | [diff] [blame] | 150 | |
| 151 | if [[ -z "$ANDROID_BUILD_TOP" ]]; then |
| 152 | echo ANDROID_BUILD_TOP not set, bailing out |
| 153 | echo you must run lunch before running this script |
| 154 | exit 1 |
| 155 | fi |
| 156 | |
| 157 | set -e |
| 158 | cd $ANDROID_BUILD_TOP |
| 159 | |
Stefano Galarraga | 2583479 | 2020-06-11 19:02:03 +0100 | [diff] [blame] | 160 | if [ "$BUILD_AND_INSTALL" = true ]; then |
Stefano Galarraga | fdbb44e | 2021-10-04 17:20:17 +0100 | [diff] [blame] | 161 | if [ ! -z "$NNAPI_SL_FILTER_OPT" ]; then |
| 162 | SL_PREBUILT=test/mlts/benchmark/sl_prebuilt |
| 163 | if [ ! -n "$(ls -A $SL_PREBUILT/*.so 2>/dev/null)" ]; then |
| 164 | echo "There is no NNAPI SL binary file under $ANDROID_BUILD_TOP/$SL_PREBUILT, cannot test using NNAPI SL" |
| 165 | exit |
| 166 | fi |
| 167 | if [ ! -f "$SL_PREBUILT/Android.bp" ]; then |
| 168 | echo "================================================================" |
| 169 | echo "Enabling build of NNAPI SL libraries using template definition." |
| 170 | echo "If the definitions in $SL_PREBUILT/Android.bp don't match the libraries you copied" |
| 171 | echo " please define your own version of $SL_PREBUILT/Android.bp" |
| 172 | echo "================================================================" |
| 173 | mv $SL_PREBUILT/Android.bp.template $SL_PREBUILT/Android.bp |
| 174 | fi |
| 175 | fi |
| 176 | |
Stefano Galarraga | 2583479 | 2020-06-11 19:02:03 +0100 | [diff] [blame] | 177 | # Build and install benchmark app |
| 178 | TMPFILE=$(mktemp) |
| 179 | build/soong/soong_ui.bash --make-mode ${APP} 2>&1 | tee ${TMPFILE} |
| 180 | TARGET_ARCH=$(cat ${TMPFILE} | grep TARGET_ARCH= | sed -e 's/TARGET_ARCH=//') |
| 181 | if [ "${TARGET_ARCH}" = "aarch64" ]; then |
| 182 | APK_DIR=arm64 |
| 183 | else |
| 184 | APK_DIR=${TARGET_ARCH} |
| 185 | fi |
Stefano Galarraga | fdbb44e | 2021-10-04 17:20:17 +0100 | [diff] [blame] | 186 | |
| 187 | if [ ! -z "$NNAPI_SL_FILTER_OPT" ]; then |
| 188 | if [ "$(unzip -l $OUT/testcases/${APP}/${APK_DIR}/${APP}.apk | grep libnnapi_sl_driver | wc -l)" -ne 1 ]; then |
| 189 | echo "NNAPI SL Libraries are not included in the APK" \ |
| 190 | "please check the library list is included in the LOCAL_JNI_SHARED_LIBRARIES list " \ |
| 191 | "for ${APP}. Please check the value of SL_LIBS in Android.mk" |
| 192 | exit |
| 193 | fi |
| 194 | fi |
| 195 | |
Stefano Galarraga | 2583479 | 2020-06-11 19:02:03 +0100 | [diff] [blame] | 196 | if ! adb install -r $OUT/testcases/${APP}/${APK_DIR}/${APP}.apk; then |
| 197 | adb uninstall com.android.nn.benchmark.app |
| 198 | adb install -r $OUT/testcases/${APP}/${APK_DIR}/${APP}.apk |
| 199 | fi |
Przemyslaw Szczepaniak | 9429af4 | 2018-09-28 17:07:24 +0100 | [diff] [blame] | 200 | |
Stefano Galarraga | 2583479 | 2020-06-11 19:02:03 +0100 | [diff] [blame] | 201 | if [ "$INSTALL_NATIVE_TESTS" = true ]; then |
| 202 | build/soong/soong_ui.bash --make-mode nn_stress_test |
| 203 | adb push $OUT/system/bin/nn_stress_test /bin/ |
| 204 | fi |
Stefano Galarraga | f03d573 | 2020-06-08 19:18:24 +0100 | [diff] [blame] | 205 | fi |
Przemyslaw Szczepaniak | 6526a9b | 2018-11-02 13:06:11 +0000 | [diff] [blame] | 206 | |
Przemyslaw Szczepaniak | f1e9334 | 2018-10-10 14:16:53 +0100 | [diff] [blame] | 207 | # Should we figure out if we run on release device |
| 208 | if [ -z "$MLTS_RELEASE_DEVICE" ]; then |
Przemyslaw Szczepaniak | 15c1f35 | 2018-10-18 13:14:34 +0100 | [diff] [blame] | 209 | BUILD_DESCRIPTION=`adb shell getprop ro.build.description` |
Przemyslaw Szczepaniak | f1e9334 | 2018-10-10 14:16:53 +0100 | [diff] [blame] | 210 | if [[ $BUILD_DESCRIPTION =~ .*release.* ]] |
| 211 | then |
| 212 | MLTS_RELEASE_DEVICE=True |
| 213 | else |
| 214 | MLTS_RELEASE_DEVICE=False |
| 215 | fi |
| 216 | fi |
| 217 | |
Przemyslaw Szczepaniak | 6526a9b | 2018-11-02 13:06:11 +0000 | [diff] [blame] | 218 | # Pass --no-isolated-storage to am instrument? |
| 219 | BUILD_VERSION_RELEASE=`adb shell getprop ro.build.version.release` |
Stefano Galarraga | 3860feb | 2021-09-22 19:13:22 +0100 | [diff] [blame] | 220 | AM_INSTRUMENT_FLAGS="$DRIVER_FILTER_OPT $INCLUDE_NNAPI_REF_OPT $NNAPI_SL_FILTER_OPT $MODEL_FILTER_OPT" |
Przemyslaw Szczepaniak | 6526a9b | 2018-11-02 13:06:11 +0000 | [diff] [blame] | 221 | if [[ $BUILD_VERSION_RELEASE == "Q" ]]; then |
Stefano Galarraga | 06ec72b | 2020-05-29 10:47:31 +0100 | [diff] [blame] | 222 | AM_INSTRUMENT_FLAGS+=" --no-isolated-storage" |
Przemyslaw Szczepaniak | 6526a9b | 2018-11-02 13:06:11 +0000 | [diff] [blame] | 223 | fi |
| 224 | |
Stefano Galarraga | 38292a9 | 2020-06-09 16:40:19 +0100 | [diff] [blame] | 225 | if [[ "$MODE" == "scoring" ]]; then |
| 226 | if [[ "$MLTS_RELEASE_DEVICE" == "True" ]]; then |
| 227 | TEST_EXTENRAL_STORAGE="com.android.nn.benchmark.app/com.android.nn.benchmark.util.TestExternalStorageActivity" |
| 228 | while ! adb shell "am start -W $TEST_EXTENRAL_STORAGE && rm /sdcard/mlts_write_external_storage" > /dev/null 2>&1; do |
| 229 | echo "************************************************************" |
| 230 | echo "Grant External storage write permissions to MLTS to proceed!" |
| 231 | echo "************************************************************" |
| 232 | read -n 1 -r -p "Continue? (press any key)" |
| 233 | echo |
| 234 | done |
| 235 | else |
| 236 | adb root |
| 237 | adb shell "pm grant com.android.nn.benchmark.app android.permission.WRITE_EXTERNAL_STORAGE" |
| 238 | # Skip setup wizard and remount (read-write) |
| 239 | if ! adb shell test -f /data/local.prop; then |
| 240 | adb shell 'echo ro.setupwizard.mode=DISABLED > /data/local.prop' |
| 241 | adb shell 'chmod 644 /data/local.prop' |
| 242 | adb shell 'settings put global device_provisioned 1*' |
| 243 | adb shell 'settings put secure user_setup_complete 1' |
| 244 | adb disable-verity |
| 245 | adb reboot |
| 246 | sleep 5 |
| 247 | adb wait-for-usb-device root |
| 248 | adb wait-for-usb-device remount |
| 249 | sleep 5 |
| 250 | fi |
| 251 | set +e |
| 252 | # Enable menu key press through adb |
| 253 | adb shell 'echo testing > /data/local/enable_menu_key' |
| 254 | # Leave screen on (affects scheduling) |
| 255 | adb shell settings put system screen_off_timeout 86400000 |
| 256 | # Stop background apps, seem to take ~10% CPU otherwise |
| 257 | adb shell 'pm disable com.google.android.googlequicksearchbox' |
| 258 | adb shell 'pm list packages -f' | sed -e 's/.*=//' | sed 's/\r//g' | grep "com.breel.wallpapers" | while read pkg; do adb shell "pm disable $pkg"; done; |
| 259 | set -e |
Przemyslaw Szczepaniak | f1e9334 | 2018-10-10 14:16:53 +0100 | [diff] [blame] | 260 | fi |
Przemyslaw Szczepaniak | f1e9334 | 2018-10-10 14:16:53 +0100 | [diff] [blame] | 261 | fi |
| 262 | |
Przemyslaw Szczepaniak | 15c1f35 | 2018-10-18 13:14:34 +0100 | [diff] [blame] | 263 | adb shell setprop debug.nn.cpuonly 0 |
Stefano Galarraga | 4edc2ea | 2020-03-02 15:38:02 +0000 | [diff] [blame] | 264 | adb shell setprop debug.nn.vlog "''" |
Przemyslaw Szczepaniak | 9429af4 | 2018-09-28 17:07:24 +0100 | [diff] [blame] | 265 | |
Przemyslaw Szczepaniak | 9429af4 | 2018-09-28 17:07:24 +0100 | [diff] [blame] | 266 | # Menukey - make sure screen is on |
| 267 | adb shell "input keyevent 82" |
| 268 | # Show homescreen |
| 269 | adb shell wm dismiss-keyguard |
Stefano Galarraga | 38292a9 | 2020-06-09 16:40:19 +0100 | [diff] [blame] | 270 | |
| 271 | if [[ "$MODE" == "scoring" ]]; then |
| 272 | LOGDIR=$(mktemp -d)/mlts-logs |
| 273 | HOST_CSV=$LOGDIR/benchmark.csv |
| 274 | RESULT_HTML=$LOGDIR/result.html |
| 275 | DEVICE_CSV=/sdcard/mlts_benchmark.csv |
| 276 | |
| 277 | mkdir -p $LOGDIR |
| 278 | echo Creating logs in $LOGDIR |
| 279 | |
| 280 | # Remove old benchmark csv data |
| 281 | adb shell rm -f ${DEVICE_CSV} |
| 282 | fi |
Slava Shklyaev | e8198d4 | 2019-05-15 16:43:46 +0100 | [diff] [blame] | 283 | |
Przemyslaw Szczepaniak | 9429af4 | 2018-09-28 17:07:24 +0100 | [diff] [blame] | 284 | # Set the shell pid as a top-app and run tests |
Slava Shklyaev | e8198d4 | 2019-05-15 16:43:46 +0100 | [diff] [blame] | 285 | time adb shell "echo $$ > /dev/stune/top-app/tasks; am instrument ${AM_INSTRUMENT_FLAGS} -w -e class $CLASS com.android.nn.benchmark.app/androidx.test.runner.AndroidJUnitRunner" |
Przemyslaw Szczepaniak | 9429af4 | 2018-09-28 17:07:24 +0100 | [diff] [blame] | 286 | |
Stefano Galarraga | 38292a9 | 2020-06-09 16:40:19 +0100 | [diff] [blame] | 287 | if [[ "$MODE" == "scoring" ]]; then |
| 288 | adb pull $DEVICE_CSV $HOST_CSV |
| 289 | echo Benchmark data saved in $HOST_CSV |
| 290 | |
| 291 | $ANDROID_BUILD_TOP/test/mlts/benchmark/results/generate_result.py $HOST_CSV $RESULT_HTML |
| 292 | echo Results stored in $RESULT_HTML |
| 293 | xdg-open $RESULT_HTML |
| 294 | fi |