1# TensorFlow Model Benchmark Tool 2 3## Description 4 5A simple C++ binary to benchmark a compute graph and its individual operators, 6both on desktop machines and on Android. 7 8## To build/install/run 9 10### On Android: 11 12(0) Refer to https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android 13to edit the `WORKSPACE` to configure the android NDK/SDK. 14 15(1) build for your specific platform, e.g.: 16 17``` 18bazel build -c opt \ 19 --crosstool_top=//external:android/crosstool \ 20 --cpu=armeabi-v7a \ 21 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ 22 --config monolithic \ 23 tensorflow/tools/benchmark:benchmark_model 24``` 25 26(2) Connect your phone. Push the binary to your phone with adb push 27 (make the directory if required): 28 29``` 30adb push bazel-bin/tensorflow/tools/benchmark/benchmark_model /data/local/tmp 31``` 32 33(3) Push the compute graph that you need to test. For example: 34 35``` 36adb push tensorflow_inception_graph.pb /data/local/tmp 37``` 38 39(4) Run the benchmark. For example: 40 41``` 42adb shell /data/local/tmp/benchmark_model \ 43 --graph=/data/local/tmp/tensorflow_inception_graph.pb \ 44 --input_layer="input:0" \ 45 --input_layer_shape="1,224,224,3" \ 46 --input_layer_type="float" \ 47 --output_layer="output:0" 48``` 49 50### On desktop: 51(1) build the binary 52 53``` 54bazel build -c opt tensorflow/tools/benchmark:benchmark_model 55``` 56 57(2) Run on your compute graph, similar to the Android case but without the need 58of adb shell. For example: 59 60``` 61bazel-bin/tensorflow/tools/benchmark/benchmark_model \ 62 --graph=tensorflow_inception_graph.pb \ 63 --input_layer="input:0" \ 64 --input_layer_shape="1,224,224,3" \ 65 --input_layer_type="float" \ 66 --output_layer="output:0" 67``` 68 69The Inception graph used as an example here may be downloaded from 70https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip 71