B
    Ù»ˆd«
  ã               @   sB   d Z ddlZddlmZ dgZejgZdd„ Zdd„ Zd	d
„ Z	dS )z5Helpers to traverse the Dataset dependency structure.é    N)ÚdtypesZDummyIterationCounterc             C   s|   g }t  ¡ }| | jj¡ g }xX| ¡ sv| ¡ }| |¡ ||ƒrL| |¡ x&|jD ]}|j}||krT| |¡ qTW q W |S )zBTraverse a dataset graph, returning nodes matching `op_filter_fn`.)	ÚqueueÚQueueÚputZ_variant_tensorÚopÚemptyÚgetÚappendÚinputs)ÚdatasetZop_filter_fnÚresultZbfs_qÚvisitedr   ÚiZinput_op© r   úV/var/www/html/venv/lib/python3.7/site-packages/tensorflow/python/data/util/traverse.pyÚ	_traverse   s    


r   c             C   s   dd„ }t | |ƒS )aH  Given an input dataset, finds all allowlisted ops used for construction.

  Allowlisted ops are stateful ops which are known to be safe to capture by
  value.

  Args:
    dataset: Dataset to find allowlisted stateful ops for.

  Returns:
    A list of variant_tensor producing dataset ops used to construct this
    dataset.
  c             S   s   | j d jtkp| jtkS )Nr   )ÚoutputsÚdtypeÚTENSOR_TYPES_ALLOWLISTÚtypeÚOP_TYPES_ALLOWLIST)r   r   r   r   Úcapture_by_value<   s    z5obtain_capture_by_value_ops.<locals>.capture_by_value)r   )r   r   r   r   r   Úobtain_capture_by_value_ops.   s    r   c             C   s   t | dd„ ƒS )a¯  Given an input dataset, finds all dataset ops used for construction.

  A series of transformations would have created this dataset with each
  transformation including zero or more Dataset ops, each producing a dataset
  variant tensor. This method outputs all of them.

  Args:
    dataset: Dataset to find variant tensors for.

  Returns:
    A list of variant_tensor producing dataset ops used to construct this
    dataset.
  c             S   s   | j d jtjkS )Nr   )r   r   r   Úvariant)r   r   r   r   Ú<lambda>Q   ó    z/obtain_all_variant_tensor_ops.<locals>.<lambda>)r   )r   r   r   r   Úobtain_all_variant_tensor_opsC   s    r   )
Ú__doc__r   Ztensorflow.python.frameworkr   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   