B
    лdG                 @   s  d Z ddlZddlZddlmZ ddlmZ ddlmZ dZ	dd Z
edkre Zed	d
dd  ejdeddd ejdddd
ddd ejdeddd ejdddd
ddd ejdeddd ejdeddd ejdeejjd d e \Z	Zeje
ejd ge d! dS )"a  Removes unneeded nodes from a GraphDef file.

This script is designed to help streamline models, by taking the input and
output nodes that will be used by an application and figuring out the smallest
set of operations that are required to run for those arguments. The resulting
minimal graph is then saved out.

The advantages of running this script are:
 - You may be able to shrink the file size.
 - Operations that are unsupported on your platform but still present can be
   safely removed.
The resulting graph may not be as flexible as the original though, since any
input nodes that weren't explicitly mentioned may not be accessible any more.

An example of command-line usage is:
bazel build tensorflow/python/tools:strip_unused && \
bazel-bin/tensorflow/python/tools/strip_unused \
--input_graph=some_graph_def.pb \
--output_graph=/tmp/stripped_graph.pb \
--input_node_names=input0
--output_node_names=softmax

You can also look at strip_unused_test.py for an example of how to use it.

    N)app)dtypes)strip_unused_libc          	   C   s(   t tjtjtjtjtjtjtj	 d S )N)
r   Zstrip_unused_from_filesFLAGSZinput_graphZinput_binaryZoutput_graphZoutput_binaryZinput_node_namesZoutput_node_namesZplaceholder_type_enum)Zunused_args r   V/var/www/html/venv/lib/python3.7/site-packages/tensorflow/python/tools/strip_unused.pymain3   s    r   __main__typeboolc             C   s   |   dkS )Ntrue)lower)vr   r   r   <lambda>?       r   z--input_graph z#TensorFlow 'GraphDef' file to load.)r
   defaulthelpz--input_binary?TFz-Whether the input files are in binary format.)nargsconstr
   r   r   z--output_graphzOutput 'GraphDef' file name.z--output_binaryz'Whether to write a binary format graph.z--input_node_namesz-The name of the input nodes, comma separated.z--output_node_namesz.The name of the output nodes, comma separated.z--placeholder_type_enumz+The AttrValue enum to use for placeholders.)r   argv)__doc__argparsesysZabslr   Ztensorflow.python.frameworkr   Ztensorflow.python.toolsr   r   r   __name__ArgumentParserparserregisteradd_argumentstrintZfloat32Zas_datatype_enumparse_known_argsZunparsedrunr   r   r   r   r   <module>'   sf   

