Skip to content

Instantly share code, notes, and snippets.

@emakryo
Last active November 19, 2020 06:46
Show Gist options
  • Save emakryo/89a61bdd798a81eedddeaf39ac0b234b to your computer and use it in GitHub Desktop.
Save emakryo/89a61bdd798a81eedddeaf39ac0b234b to your computer and use it in GitHub Desktop.
#!/bin/bash
set -ex
# Download files
BENCHMARK_BIN=android_aarch64_benchmark_model
if [[ ! -f $BENCHMARK_BIN ]]; then
wget -O $BENCHMARK_BIN https://storage.googleapis.com/tensorflow-nightly-public/prod/tensorflow/release/lite/tools/nightly/latest/android_aarch64_benchmark_model
chmod 755 $BENCHMARK_BIN
fi
if [[ ! -d hexagon_nn_skel_v1.20.0.0 ]]; then
wget https://storage.googleapis.com/download.tensorflow.org/tflite/hexagon_nn_skel_v1.20.0.0.run
chmod 755 hexagon_nn_skel_v1.20.0.0.run
echo "I ACCEPT" | ./hexagon_nn_skel_v1.20.0.0.run
fi
if [[ ! -d hexagon ]]; then
wget https://storage.googleapis.com/mirror.tensorflow.org/storage.cloud.google.com/download.tensorflow.org/tflite/hexagon_nn_headers_v1.20.0.0.tgz
tar xvf hexagon_nn_headers_v1.20.0.0.tgz
fi
#MODEL=efficientnet-lite0-int8.tflite
#if [[ ! -d efficientnet-lite0 ]]; then
# wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientnet/lite/efficientnet-lite0.tar.gz
# tar xvf efficientnet-lite0.tar.gz
#fi
MODEL=efficientnet-lite192x640.tflite
if [[ ! -f $MODEL ]]; then
echo No model file found
exit 1
fi
# Push binaries to device
DEVICE_ROOT=/data/local/tmp/efficientnet-lite0
adb shell mkdir -p $DEVICE_ROOT
adb push hexagon/arm64-v8a/libhexagon_interface.so $DEVICE_ROOT
adb push hexagon_nn_skel_v1.20.0.0/*.so $DEVICE_ROOT
adb push $BENCHMARK_BIN $DEVICE_ROOT
adb push $MODEL $DEVICE_ROOT
# Execute
adb shell "\
cd $DEVICE_ROOT;
LD_LIBRARY_PATH=$DEVICE_ROOT \
PATH=$DEVICE_ROOT \
$BENCHMARK_BIN\
--benchmark_name=bench01\
--graph=$MODEL\
--num_runs=10\
--use_hexagon=true\
--input_layer=input_1\
--input_layer_shape=1,192,640,3\
--hexagon_lib_path=$DEVICE_ROOT"
#--input_layer=input_1\
#--input_layer_shape=1,224,224,3\
#--input_layer_value_files=input_1:zeros.bin\
# adb shell ls -l $DEVICE_ROOT
# Clean up
adb shell rm $DEVICE_ROOT/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment