o
    i e8                     @   sv   d Z ddl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dl	m
Z
 ddlmZ eddd	gd
dddZdS )z-Utility functions for reading/writing graphs.    N)text_format)byte_swap_tensor)ops)file_io)	tf_exportzio.write_graphztrain.write_graph)v1Tc                 C   s   t | tjr|  }n| }tjdkr&t|drt|dd nt	|dd |
ds0t| tj||}|rFt|tj|dd |S t||jdd |S )	a  Writes a graph proto to a file.

  The graph is written as a text proto unless `as_text` is `False`.

  ```python
  v = tf.Variable(0, name='my_variable')
  sess = tf.compat.v1.Session()
  tf.io.write_graph(sess.graph_def, '/tmp/my-model', 'train.pbtxt')
  ```

  or

  ```python
  v = tf.Variable(0, name='my_variable')
  sess = tf.compat.v1.Session()
  tf.io.write_graph(sess.graph, '/tmp/my-model', 'train.pbtxt')
  ```

  Args:
    graph_or_graph_def: A `Graph` or a `GraphDef` protocol buffer.
    logdir: Directory where to write the graph. This can refer to remote
      filesystems, such as Google Cloud Storage (GCS).
    name: Filename for the graph.
    as_text: If `True`, writes the graph as an ASCII proto.

  Returns:
    The path of the output proto file.
  bignodelittlezgs: )float_formatT)deterministic)
isinstancer   Graphas_graph_defsys	byteorderhasattrr   !swap_tensor_content_in_graph_node%swap_tensor_content_in_graph_function
startswithr   recursive_create_dirospathjoinatomic_write_string_to_filer   MessageToStringSerializeToString)graph_or_graph_deflogdirnameas_text	graph_defr    r#   S/var/www/myenv/lib/python3.10/site-packages/tensorflow/python/framework/graph_io.pywrite_graph   s2   




r%   )T)__doc__r   os.pathr   google.protobufr   tensorflow.python.frameworkr   r   tensorflow.python.lib.ior    tensorflow.python.util.tf_exportr   r%   r#   r#   r#   r$   <module>   s   