o
    ?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: )Zfloat_formatT)Zdeterministic)
isinstancer   ZGraphZas_graph_defsys	byteorderhasattrr   Z!swap_tensor_content_in_graph_nodeZ%swap_tensor_content_in_graph_function
startswithr   Zrecursive_create_dirospathjoinZatomic_write_string_to_filer   ZMessageToStringZSerializeToString)Zgraph_or_graph_defZlogdirnameZas_textZ	graph_defr    r   e/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/framework/graph_io.pywrite_graph   s2   




r   )T)__doc__r   Zos.pathr   Zgoogle.protobufr   Ztensorflow.python.frameworkr   r   Ztensorflow.python.lib.ior   Z tensorflow.python.util.tf_exportr   r   r   r   r   r   <module>   s   