
    `i                     ^    d dl Zd dlmZmZ ddlmZmZ ddefdZ	dd	Z
d
 Zd ZddZd ZdS )    N)tree_flattentree_unflatten   )add_step_closurerun_step_closures Fdevicec                 p    t           j        j                            | g |           t	                       dS )aV  Triggers a mark step, which amounts to
    - collecting a group of 'live' lazy tensors to index into the compilation cache
      (lowering/compiling their IR graphs if not cached)
    - kicking off execution of the compiled function
    - (optionally, wait=True) waiting for cpu-side execution to complete (does not sync the accelerator)
    )waitN)torch_C_lazy
_mark_stepr   )r	   r   s     h/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/torch/_lazy/__init__.py	mark_stepr   	   s5     
HNfbt444    c                 X    | g } t           j        j                            |            dS )zWaits for all the async operations on the given devices to complete.
    Args:
      devices (string..., optional): The devices whose async ops need to be waited
        for. If empty, all the local devices will be waited for.
    Ndevices)r   r   r   _wait_device_opsr   s    r   wait_device_opsr      s/     	HN##G#44444r   c                 P    t           j        j                            | |           dS )z
    Sync the list of lazy tensors so there IR get lowered for the activate backend
    and the compiled computation graph get cached.
    N)r   r   r   _sync_multi)tensorsr   s     r   
sync_multir   !   s$    
 
HNw00000r   c                 J    t           j        j                            |           S )z7Return a unique id of the lazy tensor maintained by LTC)r   r   r   _get_tensor_id)tensors    r   get_tensor_idr   )   s    8>((000r   c                     |pdg}t          |           \  }}t          ||           t          d |D             |          S )Nlazyc                 8    g | ]}|                     d           S )cpu)to).0ts     r   
<listcomp>zto_cpu.<locals>.<listcomp>3   s"    :::1144;;:::r   )r   r   r   )r   r   	flattenedspecs       r   to_cpur*   .   sN    !&G"7++OIty'"""::	:::DAAAr   c                 J    t          j        t          |           g|R i | d S N)r   saver*   )r   argskwargss      r   r-   r-   6   s.    	Jvg000000000r   )r   Fr,   )torch._C._lazyr   torch.utils._pytreer   r   closurer   r   strr   r   r   r   r*   r-    r   r   <module>r5      s        < < < < < < < < 8 8 8 8 8 8 8 8
 
c 
 
 
 
5 5 5 51 1 11 1 1
B B B B1 1 1 1 1r   