Search code examples
buildtensorflowobject-detection

Tensorflow transform_graph doesn't have quantize_weights


I am building Tensorflow on Windows Server 2012 R2 from git. When I build the target tensorflow/tools/graph_transforms:transform_graph, it builds correctly but the quantize_weights transform isn't available. This is the output of running transform_graph:

$ bazel-bin/tensorflow/tools/graph_transforms/transform_graph --in_graph=/c/Users/name/git-repos/project/input/file.pb --out_graph=/c/Users/name/git-repos/project/input/file_q.pb --inputs='image_tensor' --outputs='detection_boxes,detection_scores,detection_classes' --transforms='fold_constants(ignore_error=true)
fold_batch_norms
fold_old_batch_norms
quantize_weights'
2017-07-06 13:21:10.361492: I C:\tools\msys64\tmp\_bazel_name\avtc4yfu\execroot\tensorflow\tensorflow\tools\graph_transforms\transform_graph.cc:263] Applying fold_constants
2017-07-06 13:21:10.476001: W C:\tools\msys64\tmp\_bazel_name\avtc4yfu\execroot\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-06 13:21:13.241688: I C:\tools\msys64\tmp\_bazel_name\avtc4yfu\execroot\tensorflow\tensorflow\tools\graph_transforms\transform_graph.cc:263] Applying fold_batch_norms
2017-07-06 13:21:16.088969: I C:\tools\msys64\tmp\_bazel_name\avtc4yfu\execroot\tensorflow\tensorflow\tools\graph_transforms\transform_graph.cc:263] Applying fold_old_batch_norms
2017-07-06 13:21:16.650913: E C:\tools\msys64\tmp\_bazel_name\avtc4yfu\execroot\tensorflow\tensorflow\tools\graph_transforms\transform_graph.cc:209] Transform 'quantize_weights' not recognized.
2017-07-06 13:21:16.650934: E C:\tools\msys64\tmp\_bazel_name\avtc4yfu\execroot\tensorflow\tensorflow\tools\graph_transforms\transform_graph.cc:210] usage: C:\Users\name\git-repos\tensorflow\bazel-bin\tensorflow\tools\graph_transforms\transform_graph.exe
Flags:
        --in_graph=""                           string  input graph file name
        --out_graph=""                          string  output graph file name
        --inputs=""                             string  inputs
        --outputs=""                            string  outputs
        --transforms=""                         string  list of transforms
        --output_as_text=false                  bool    whether to write the graph in text protobuf format

Transforms are:
add_default_attributes
backport_concatv2
backport_tensor_array_v3
fold_batch_norms
fold_constants
fold_old_batch_norms
freeze_requantization_ranges
fuse_pad_and_conv
fuse_resize_and_conv
fuse_resize_pad_and_conv
insert_logging
obfuscate_names
remove_attribute
remove_device
remove_nodes
rename_attribute
rename_op
set_device
sort_by_execution_order
sparsify_gather
strip_unused_nodes

Why aren't all the transforms available? I've tried rebuilding with bazel clean as well.


Solution

  • I think this is an issue with the Windows builds of TensorFlow unfortunately. There are problems compiling the https://github.com/google/gemmlowp library that the quantization parts of TF rely on, so anything that relies on them (like quantize_weights) is disabled in cmake. It would be worth filing a bug on this at https://github.com/tensorflow/tensorflow/issues