STT-tensorflow/tensorflow/tools/benchmark
A. Unique TensorFlower 5d3c548620 Resolve trivial aliases for portable TensorFlow targets.
PiperOrigin-RevId: 311548335
Change-Id: I837aa5a62500682783607841f0c993c2b6c238ed
2020-05-14 09:39:36 -07:00
..
benchmark_model_main.cc Update copyright for 3p/tf/tools. 2016-06-02 11:47:17 -07:00
benchmark_model_test.cc Allow benchmark model graph to be specified in text proto format. 2018-05-07 15:45:26 -07:00
benchmark_model.cc [Build cleanup] Update #includes of moved header "graph/graph_constructor.h". 2020-04-29 09:20:48 -07:00
benchmark_model.h Add init op and target node support to benchmark 2018-03-08 08:27:35 -08:00
BUILD Resolve trivial aliases for portable TensorFlow targets. 2020-05-14 09:39:36 -07:00
README.md fix unbalanced delimiter in benchmark_model doc 2018-09-26 13:23:14 +08:00

TensorFlow Model Benchmark Tool

Description

A simple C++ binary to benchmark a compute graph and its individual operators, both on desktop machines and on Android.

To build/install/run

On Android:

(0) Refer to https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android to edit the WORKSPACE to configure the android NDK/SDK.

(1) build for your specific platform, e.g.:

bazel build -c opt \
  --crosstool_top=//external:android/crosstool \
  --cpu=armeabi-v7a \
  --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
  --config monolithic \
  tensorflow/tools/benchmark:benchmark_model

(2) Connect your phone. Push the binary to your phone with adb push (make the directory if required):

adb push bazel-bin/tensorflow/tools/benchmark/benchmark_model /data/local/tmp

(3) Push the compute graph that you need to test. For example: adb push tensorflow_inception_graph.pb /data/local/tmp

(4) Run the benchmark. For example:

adb shell /data/local/tmp/benchmark_model \
  --graph=/data/local/tmp/tensorflow_inception_graph.pb \
  --input_layer="input:0" \
  --input_layer_shape="1,224,224,3" \
  --input_layer_type="float" \
  --output_layer="output:0"

On desktop:

(1) build the binary

bazel build -c opt tensorflow/tools/benchmark:benchmark_model

(2) Run on your compute graph, similar to the Android case but without the need of adb shell. For example:

bazel-bin/tensorflow/tools/benchmark/benchmark_model \
  --graph=tensorflow_inception_graph.pb \
  --input_layer="input:0" \
  --input_layer_shape="1,224,224,3" \
  --input_layer_type="float" \
  --output_layer="output:0"

The Inception graph used as an example here may be downloaded from https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip