U
    <ºc  ã                   @   s0   d dl mZ daedd„ ƒZdd„ Zdd„ Zd	S )
é    )ÚcontextmanagerFc                 c   s   t }| a z
dV  W 5 |a X dS )aÇ  
    A context manager to tag tensors in the forward pass of DDP to be
    ``ReplicatedTensor``. This can be used by ReplicatedTensor inter-op
    during the forward pass to perform appropriate optimizations.

    This context manager needs to wrap DDP creation and modifying the underlying
    module passed into DDP after leaving this context manager would cause
    inconsitencies and the changes will not be picked up during the forward
    pass.
    N©Ú_DDP_WITH_REPLICATED_TENSOR)ÚvalZold_val© r   úR/tmp/pip-unpacked-wheel-gikjz4vx/torch/nn/parallel/_replicated_tensor_ddp_utils.pyÚ_ddp_replicated_tensor   s
    
r   c                   C   s   t S ©Nr   r   r   r   r   Ú#_ddp_with_replicated_tensor_enabled   s    r
   c                 C   s   | a d S r	   r   )Úvaluer   r   r   Ú_set_ddp_with_replicated_tensor   s    r   N)Ú
contextlibr   r   r   r
   r   r   r   r   r   Ú<module>   s
   
