
    BVh                     v    d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z
  ej                         ZdZ	 	 	 	 d	dZy)
zCProvides a proper python API for the symbols exported through swig.    N)	graph_pb2)
config_pb2)_pywrap_tf_optimizer)clusterTc           	      z   t        | t        j                        s!t        dt	        |       j
                         t        r!t        j                  }|j                         }nt        j                  }|& ||j                  | j                         ||||      }nZt        5  t        j                         }	  ||j                  | j                         ||||      }|j                          	 ddd       t        rt         j"                  j%                        }S # |j                          w xY w# 1 sw Y   ExY w)a	  Optimize the provided metagraph.

  For best results, the signature_def field in `metagraph` should be populated
  with information about input (feed) and output (fetch) tensors.

  Args:
    config_proto: a ConfigProto protobuf.
    metagraph: a MetagraphDef protobuf.
    verbose: whether to log optimization results.
    graph_id: a string identifying this graph.
    cluster: a grappler cluster object representing hardware resources
        available to run this graph.
    strip_default_attributes: whether graph node attributes having default
        values should be removed after all the optimization passes. This
        option is useful if the resulting graph will be executed by an older
        process that might not know some of the recently added attributes.
  zCArgument `config_proto` should be a tf.ConfigProto, received type: N)
isinstancer   ConfigProto	TypeErrortype__name__is_osstf_optTF_OptimizeGraphSerializedSerializeToStringTF_OptimizeGraph
tf_cluster_OPTIMIZE_GRAPH_CLUSTER_LOCKgclusterClusterShutdownr   GraphDef
FromString)config_proto	metagraphverbosegraph_idr   strip_default_attributesoptimize_method	out_graphs           W/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/grappler/tf_optimizer.pyOptimizeGraphr!      s.   . 
L*"8"8	9
 &&*<&8&A&A%BD E E77O++-I--O&&( I 
&   "g#**,$
	 	  ""--i8I	 	 s$   !D17%DD1D..D11D:)Ts   graph_to_optimizeNF)__doc__	threadingtensorflow.core.frameworkr   tensorflow.core.protobufr   tensorflow.python.grapplerr   r   r   r   Lockr   r   r!        r    <module>r*      sA    J  / / E :-y~~/ 	
 /+0?r)   