diff options
author | Nupur Garg <nupurgarg@google.com> | 2018-06-05 16:15:55 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-06-05 16:18:44 -0700 |
commit | 677c83e6ba6fdc4d23f8c26bfc84209be4371631 (patch) | |
tree | aa65dc1d924c64aee092698b47af55c7a1b581fa | |
parent | ece5f512538f66b69db52b8a5b6f9669ae10a3d9 (diff) |
Updates Python TOCO command line and TOCO documentation.
PiperOrigin-RevId: 199375811
-rw-r--r-- | tensorflow/contrib/lite/python/tflite_convert.py | 11 | ||||
-rw-r--r-- | tensorflow/contrib/lite/toco/g3doc/cmdline_examples.md | 45 | ||||
-rw-r--r-- | tensorflow/contrib/lite/toco/g3doc/cmdline_reference.md | 10 |
3 files changed, 6 insertions, 60 deletions
diff --git a/tensorflow/contrib/lite/python/tflite_convert.py b/tensorflow/contrib/lite/python/tflite_convert.py index d0879daed2..6d77626a4b 100644 --- a/tensorflow/contrib/lite/python/tflite_convert.py +++ b/tensorflow/contrib/lite/python/tflite_convert.py @@ -161,7 +161,8 @@ def _check_flags(flags, unparsed): output += _get_message_unparsed(flag, "--input_file", "--graph_def_file") output += _get_message_unparsed(flag, "--std_value", "--std_dev_values") output += _get_message_unparsed(flag, "--batch_size", "--input_shapes") - raise ValueError(output) + if output: + raise ValueError(output) # Check that flags are valid. if flags.graph_def_file and (not flags.input_arrays or @@ -285,13 +286,13 @@ def run_main(_): # Graph manipulation flags. parser.add_argument( "--drop_control_dependency", - type=bool, + action="store_true", help=("Boolean indicating whether to drop control dependencies silently. " "This is due to TensorFlow not supporting control dependencies. " "(default True)")) parser.add_argument( "--reorder_across_fake_quant", - type=bool, + action="store_true", help=("Boolean indicating whether to reorder FakeQuant nodes in " "unexpected locations. Used when the location of the FakeQuant " "nodes is preventing graph transformations necessary to convert " @@ -300,13 +301,13 @@ def run_main(_): "behavior. (default False)")) parser.add_argument( "--change_concat_input_ranges", - type=bool, + action="store_true", help=("Boolean to change behavior of min/max ranges for inputs and " "outputs of the concat operator for quantized models. Changes the " "ranges of concat operator overlap when true. (default False)")) parser.add_argument( "--allow_custom_ops", - type=bool, + action="store_true", help=("Boolean indicating whether to allow custom operations. When false " "any unknown operation is an error. When true, custom ops are " "created for any op that is unknown. The developer will need to " diff --git a/tensorflow/contrib/lite/toco/g3doc/cmdline_examples.md b/tensorflow/contrib/lite/toco/g3doc/cmdline_examples.md index 7680cdd344..8e93f02ef1 100644 --- a/tensorflow/contrib/lite/toco/g3doc/cmdline_examples.md +++ b/tensorflow/contrib/lite/toco/g3doc/cmdline_examples.md @@ -26,8 +26,6 @@ Table of contents: * [Convert a TensorFlow Lite FlatBuffer back into TensorFlow GraphDef format](#to-graphdef) * [Logging](#logging) - * [Standard logging](#standard-logging) - * [Verbose logging](#verbose-logging) * [Graph "video" logging](#graph-video-logging) * [Graph visualizations](#graph-visualizations) * [Using --output_format=GRAPHVIZ_DOT](#using-output-formatgraphviz-dot) @@ -277,49 +275,6 @@ bazel run --config=opt \ ## Logging -### Standard logging - -The converter generates some informative log messages during processing. The -easiest way to view them is to add `--logtostderr` to command lines as seen in -the following example. - -``` -curl https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_0.50_128_frozen.tgz \ - | tar xzv -C /tmp -bazel run --config=opt \ - //tensorflow/contrib/lite/toco:toco -- \ - --input_file=/tmp/mobilenet_v1_0.50_128/frozen_graph.pb \ - --output_file=/tmp/foo.tflite \ - --input_format=TENSORFLOW_GRAPHDEF \ - --output_format=TFLITE \ - --inference_type=FLOAT \ - --input_shape=1,128,128,3 \ - --input_array=input \ - --output_array=MobilenetV1/Predictions/Reshape_1 \ - --logtostderr -``` - -After some initialization messages, we get the following informative messages: - -``` -I1101 21:51:33.297475 5339 graph_transformations.cc:39] Before general graph transformations: 416 operators, 583 arrays (0 quantized) -I1101 21:51:33.308972 5339 graph_transformations.cc:39] After general graph transformations pass 1: 31 operators, 89 arrays (0 quantized) -I1101 21:51:33.309204 5339 graph_transformations.cc:39] Before dequantization graph transformations: 31 operators, 89 arrays (0 quantized) -I1101 21:51:33.309368 5339 allocate_transient_arrays.cc:312] Total transient array allocated size: 1048576 bytes, theoretical optimal value: 786432 bytes. -I1101 21:51:33.309484 5339 toco_tooling.cc:249] Estimated count of arithmetic ops: 0.099218 billion (note that a multiply-add is counted as 2 ops). -``` - -### Verbose logging - -For debugging purposes, the converter supports two levels of verbose logging, -which can be set by passing a `--v=` flag: - -* For `--v=1`, the converter generates text dumps of the graph at various - points during processing as well as log messages about every graph - transformation that took place. -* For `--v=2`, the converter additionally generates log messages about graph - transformations that were considered but not performed. - ### Graph "video" logging When `--dump_graphviz=` is used (see the section on [graph diff --git a/tensorflow/contrib/lite/toco/g3doc/cmdline_reference.md b/tensorflow/contrib/lite/toco/g3doc/cmdline_reference.md index a8381169b8..8085ae0748 100644 --- a/tensorflow/contrib/lite/toco/g3doc/cmdline_reference.md +++ b/tensorflow/contrib/lite/toco/g3doc/cmdline_reference.md @@ -209,16 +209,6 @@ have. ## Logging flags -The following are standard Google logging flags: - -* `--logtostderr` redirects Google logging to standard error, typically making - it visible in a terminal. -* `--v` sets verbose logging levels (for debugging purposes). Defined levels: - * `--v=1`: log all graph transformations that did make a change on the - graph. - * `--v=2`: log all graph transformations that did *not* make a change on - the graph. - The following flags allow to generate graph visualizations of the actual graph at various points during transformations: |