U
    Jc(                     @   sT   d dl Zd dl mZ d dlmZ d dlmZ dgZeddG dd dejj	Z
dS )	    N)Node)compatibility)FakeTensorModeFakeTensorPropF)Zis_backward_compatiblec                       s2   e Zd ZdZed fddZ fddZ  ZS )r   a  
    Execute an FX graph Node-by-Node and record a fake tensor representing
    the metadata for the node.  Unlike ShapeProp, (1) this propagation
    is cheap--it does the propagation with meta tensors which do not actually
    store data, and (2) the fake tensors have much more fine grained information,
    e.g., they have accurate alias information that can be consulted by looking
    at the storages.

    Args:
         module (GraphModule): The module to be executed
    )nc                    s   t  |}||jd< |S )Nval)superrun_nodemeta)selfr   result	__class__ D/tmp/pip-unpacked-wheel-gikjz4vx/torch/fx/passes/fake_tensor_prop.pyr	      s    
zFakeTensorProp.run_nodec              
      s>   t  ,  fdd|D }t j| W  5 Q R  S Q R X d S )Nc                    s   g | ]}  |qS r   )Zfrom_tensor).0amoder   r   
<listcomp>   s     z,FakeTensorProp.propagate.<locals>.<listcomp>)r   pushr   run)r   argsZ	fake_argsr   r   r   	propagate   s    
zFakeTensorProp.propagate)__name__
__module____qualname____doc__r   r	   r   __classcell__r   r   r   r   r      s   )Ztorch.fxZtorchr   Ztorch.fx._compatibilityr   Ztorch._subclasses.fake_tensorr   __all__ZfxZInterpreterr   r   r   r   r   <module>   s   