
    Χg              
      z   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            ZddZ ddZ!ddZ"ddZ#d dZ$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              #  R  K   t          | t                    r| j        nt          | t                    r| j        n| t          fd          5  t          j        j        j	                  5  d V  d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                 (    d j          d j         S )Nzin native_functions.yaml line z:
  )locfunc)fs   L/var/www/html/ai-engine/env/lib/python3.11/site-packages/torchgen/context.py<lambda>z)native_function_manager.<locals>.<lambda>8   s    N!%NNafNN     )!use_const_ref_for_mutable_tensorsuse_ilistref_for_tensor_lists)

isinstancer   outr   viewr   localparametrizer#   part_of_structured_group)r   r   s    @r    native_function_managerr+   )   sH      !)** 

 E	A/	0	0 F	NNNN	O	O  ./.Q*+*D
 
 
 	 	 EEE		 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 s6   !B3B8BB	BB	BB #B r   Callable[[F], T]c                H     t          j                   d fd            }|S )Nr   r   r   r   c                l    t          |           5   |           cd d d            S # 1 swxY w Y   d S Nr+   )r   r   s    r    wrapperz%with_native_function.<locals>.wrapperF   s    $Q'' 	 	477	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   )--)r   r   r   r   	functoolswrapsr   r1   s   ` r    with_native_functionr6   E   s=    _T      Nr"   Callable[[F, F2], T]c                H     t          j                   d fd            }|S )	Nr   r   f2r   r   r   c                n    t          |           5   | |          cd d d            S # 1 swxY w Y   d S r/   r0   )r   r9   r   s     r    r1   z)with_native_function_and.<locals>.wrapperO   s     %Q'' 	 	42;;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   *..)r   r   r9   r   r   r   r2   r5   s   ` r    with_native_function_andr<   N   s=    _T     
 Nr"   Callable[[S, F], T]c                H     t          j                   d fd            }|S )	Nslfr   r   r   r   r   c                n    t          |          5   | |          cd d d            S # 1 swxY w Y   d S r/   r0   r?   r   r   s     r    r1   z,method_with_native_function.<locals>.wrapperY   s    $Q'' 	  	 4Q<<	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 r;   )r?   r   r   r   r   r   r2   r5   s   ` r    method_with_native_functionrB   X   s=    _T            Nr"   Callable[[S, F3], T]c                H     t          j                   d fd            }|S )	Nr?   r   r   r   r   r   c                z    t          |d                   5   | |          cd d d            S # 1 swxY w Y   d S )Nr   r0   rA   s     r    r1   z3method_with_nested_native_function.<locals>.wrapperd   s    $QqT** 	  	 4Q<<	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   044)r?   r   r   r   r   r   r2   r5   s   ` r    "method_with_nested_native_functionrF   a   s?     _T            Nr"   Callable[[F, BackendIndex], T]c                H     t          j                   d fd            }|S )	Nr   r   backend_indexr   r   r   c                n    t          |           5   | |          cd d d            S # 1 swxY w Y   d S r/   r0   )r   rI   r   s     r    r1   z/with_native_function_and_index.<locals>.wrapperq   s    $Q'' 	* 	*4=))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*r;   )r   r   rI   r   r   r   r2   r5   s   ` r    with_native_function_and_indexrK   n   s?     _T* * * * * * Nr"   1Callable[[F, dict[DispatchKey, BackendIndex]], T]c                H     t          j                   d fd            }|S )	Nr   r   backend_indicesdict[DispatchKey, BackendIndex]r   r   c                n    t          |           5   | |          cd d d            S # 1 swxY w Y   d S r/   r0   )r   rN   r   s     r    r1   z1with_native_function_and_indices.<locals>.wrapper}   s    $Q'' 	, 	,4?++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,r;   )r   r   rN   rO   r   r   r2   r5   s   ` r     with_native_function_and_indicesrQ   z   s?     _T, , , , , , Nr"   )r   r   r   r   )r   r,   r   r,   )r   r7   r   r7   )r   r=   r   r=   )r   rC   r   rC   )r   rG   r   rG   )r   rL   r   rL   )&
__future__r   
contextlibr3   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+   r6   r<   rB   rF   rK   rQ    r"   r    <module>r\      s   " " " " " "         Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q                    ) ( ( ( ( ( ( ( ( (
 G	..
./	.2
23  W^  WT5,-tN/CDD    6                    r"   