a
    d                     @   sT   U d dl mZmZ d dlmZ g Zee ed< eeeeeeeef  dddZ	dS )    )ListTuple)ShardMetadata__all__)saved_shardcurrent_shardreturnc                 C   s   g }t t| j|j| j|jD ]d\}\}}}}t|| || }|t|| }	||krdd}
|| }n|| }
d}|||
||	f q|S )aZ  
    Return the overlapping region between saved_shard and current_shard.
    There returned list has the same number of elements as the tensor's dimension.
    For each element, we produce a tuple with the following contents:
        (dimension, `saved_shard` offset, `current_shard` offset, length)

    Offsets are relative to each shard.
    r   )	enumeratezipZshard_offsetsZshard_sizesminmaxappend)r   r   ZnarrowsZdimZsaved_shard_offsetZcurrent_shard_offsetZsaved_shard_sizeZcurrent_shard_sizeZmin_range_endlengthZoffset_for_saved_tensorZoffset_for_current_tensor r   p/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torch/distributed/checkpoint/resharding.py+_shards_get_overlap_region_wrt_saved_tensor
   s:    
	
r   N)
typingr   r   Z&torch.distributed._shard.sharding_specr   r   str__annotations__intr   r   r   r   r   <module>   s
   