o
    I5i                  	   @  s   d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZmZmZmZmZ d dlmZmZmZ edeeeeeef eeef Zedeee	e eeZede
eef ee Zejd"ddZd#ddZ d$ddZ!d%ddZ"d&ddZ#d'ddZ$d(d d!Z%dS ))    )annotationsN)AnyCallableIteratorListOptionalTupleTypeVarUnion)BackendIndexDispatchKeyNativeFunctionNativeFunctionsGroupNativeFunctionsViewGroup)contextSTFF2F3g@NativeFunctionsGroup | NativeFunctionsViewGroup | NativeFunctionreturnIterator[None]c              	   #  s    t | tr
| j nt | tr| j n|  t fdd- tj j j	d d V  W d    n1 s5w   Y  W d    d S W d    d S 1 sMw   Y  d S )Nc                     s   d j  d j S )Nzin native_functions.yaml line z:
  )locfunc fr   ^/lsinfo/ai/hellotax_ai/llm_service/venv_embed/lib/python3.10/site-packages/torchgen/context.py<lambda>8   s    z)native_function_manager.<locals>.<lambda>)!use_const_ref_for_mutable_tensorsuse_ilistref_for_tensor_lists)

isinstancer   outr   viewr   localparametrizer!   part_of_structured_group)r   r   r   r   native_function_manager)   s    

"r)   r   Callable[[F], T]c                   s   t  d fdd}|S )Nr   r   r   r   c                   s4   t |   | W  d    S 1 sw   Y  d S Nr)   r   r   r   r   wrapperF   s   
$z%with_native_function.<locals>.wrapper)r   r   r   r   	functoolswrapsr   r.   r   r-   r   with_native_functionE      r3   Callable[[F, F2], T]c                      t  d	 fdd}|S )
Nr   r   f2r   r   r   c                   6   t |   | |W  d    S 1 sw   Y  d S r+   r,   )r   r7   r-   r   r   r.   O   s   
$z)with_native_function_and.<locals>.wrapper)r   r   r7   r   r   r   r/   r2   r   r-   r   with_native_function_andN   s   r9   Callable[[S, F], T]c                   r6   )
Nslfr   r   r   r   r   c                   s6   t |  | |W  d    S 1 sw   Y  d S r+   r,   r;   r   r-   r   r   r.   Y      
$z,method_with_native_function.<locals>.wrapper)r;   r   r   r   r   r   r/   r2   r   r-   r   method_with_native_functionX   r4   r>   Callable[[S, F3], T]c                   r6   )
Nr;   r   r   r   r   r   c                   s:   t |d   | |W  d    S 1 sw   Y  d S )Nr   r,   r<   r-   r   r   r.   d   s   $z3method_with_nested_native_function.<locals>.wrapper)r;   r   r   r   r   r   r/   r2   r   r-   r   "method_with_nested_native_functiona      r@   Callable[[F, BackendIndex], T]c                   r6   )
Nr   r   backend_indexr   r   r   c                   r8   r+   r,   )r   rC   r-   r   r   r.   q   r=   z/with_native_function_and_index.<locals>.wrapper)r   r   rC   r   r   r   r/   r2   r   r-   r   with_native_function_and_indexn   rA   rD   1Callable[[F, dict[DispatchKey, BackendIndex]], T]c                   r6   )
Nr   r   backend_indicesdict[DispatchKey, BackendIndex]r   r   c                   r8   r+   r,   )r   rF   r-   r   r   r.   }   r=   z1with_native_function_and_indices.<locals>.wrapper)r   r   rF   rG   r   r   r/   r2   r   r-   r    with_native_function_and_indicesz   rA   rH   )r   r   r   r   )r   r*   r   r*   )r   r5   r   r5   )r   r:   r   r:   )r   r?   r   r?   )r   rB   r   rB   )r   rE   r   rE   )&
__future__r   
contextlibr0   typingr   r   r   r   r   r   r	   r
   torchgen.localr&   torchgen.modelr   r   r   r   r   torchgen.utilsr   r   r   r   boolstrr   r   contextmanagerr)   r3   r9   r>   r@   rD   rH   r   r   r   r   <module>   s@    (

		

	


	
