o
    ۷i                     @   s   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ ddl	m
Z
 eeZdd Zejdd Zejjd	efd
dZejjdd Z			ddejdedededef
ddZdS )    N)init_logger   )current_platformc                  O   s   d S N )argskwargsr   r   E/home/ubuntu/vllm_env/lib/python3.10/site-packages/cache_dit/utils.pydummy_print   s   r
   c                  c   s    t j} tt _d V  | t _d S r   )__builtin__printr
   )origin_printr   r   r	   disable_print   s
   
r   returnc                   C   s
   t jdkS )Nz0.35.0)	diffusers__version__r   r   r   r	   is_diffusers_at_least_0_3_5   s   
r   c                   C   s`   z%t d t  t  t  t d t  t  t  W d S  ty/   Y d S w )Nr   )timesleepgccollectr   empty_cacheipc_collect	Exceptionr   r   r   r	   maybe_empty_cache   s   

r   Txnamedimno_dist_shapedisablec                    s0  |rd S  d u rt | d d S t tjs$t | dt   d S    tj rz fddttj	 D }tj
|  tj||d}|sO|j}n j}tj }t d| d| d|    d	|    d
| 
dd d S t | d     d	     d
 j  d S )Nz is Nonez is not a tensor, type: c                    s   g | ]}t  qS r   )torch
zeros_like).0_r   r   r	   
<listcomp>C   s    z print_tensor.<locals>.<listcomp>)r   z
rank: z, z, mean: z, std: z	, shape: T)flush)r   
isinstancer    Tensortype
contiguousdistributedis_initializedrangeget_world_size
all_gathercatshapeget_rankfloatmeanitemstd)r   r   r   r   r   gather_xx_shaperankr   r$   r	   print_tensor.   s@   

 
r:   )r   TT)r   r   r    r   builtinsr   
contextlibcache_dit.loggerr   	platformsr   __name__loggerr
   contextmanagerr   compilerr   boolr   r   r(   strintr:   r   r   r   r	   <module>   s<    

