a
    .=ic                  	   @   s  d dl mZmZmZ d dlmZmZmZmZm	Z	 d dl
mZ d dlZd dlmZmZmZmZmZmZ d dlZedeeeeeef eeef Zedeeee eZejeeeef ed ddd	Zeegef eegef d
ddZeeegef eeegef d
ddZeeegef eeegef d
ddZeeegef eeegef d
ddZeeee	ef gef eeee	ef gef d
ddZdS )    )STcontext)NativeFunctionNativeFunctionsGroupNativeFunctionsViewGroupBackendIndexDispatchKeyN)TypeVarUnionIteratorCallableDictOptionalFF2)greturnc              	   #   s   t | tr| j nt | tr$| j n|  t fddD tj jd d V  W d    n1 sd0    Y  W d    n1 s0    Y  d S )Nc                      s   d j  d j S )Nzin native_functions.yaml line z:
  )locfunc fr   a/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/torchgen/context.py<lambda>2       z)native_function_manager.<locals>.<lambda>)!use_const_ref_for_mutable_tensors)	
isinstancer   outr   viewr   localZparametrizer   )r   r   r   r   native_function_manager#   s    

r!   )r   r   c                    s"   t  ttd fdd}|S )N)r   r   c                    s4   t |   | W  d    S 1 s&0    Y  d S Nr!   r   r   r   r   wrapper?   s    
z%with_native_function.<locals>.wrapper)	functoolswrapsr   r   r   r%   r   r$   r   with_native_function>   s    r)   c                    s$   t  tttd fdd}|S )N)r   f2r   c                    s6   t |   | |W  d    S 1 s(0    Y  d S r"   r#   )r   r*   r$   r   r   r%   H   s    
z)with_native_function_and.<locals>.wrapper)r&   r'   r   r   r   r(   r   r$   r   with_native_function_andG   s    r+   c                    s$   t  tttd fdd}|S )N)slfr   r   c                    s6   t |  | |W  d    S 1 s(0    Y  d S r"   r#   )r,   r   r$   r   r   r%   R   s    
z,method_with_native_function.<locals>.wrapper)r&   r'   r   r   r   r(   r   r$   r   method_with_native_functionQ   s    r-   c                    s$   t  tttd fdd}|S )N)r   backend_indexr   c                    s6   t |   | |W  d    S 1 s(0    Y  d S r"   r#   )r   r.   r$   r   r   r%   _   s    
z/with_native_function_and_index.<locals>.wrapper)r&   r'   r   r   r   r(   r   r$   r   with_native_function_and_index\   s    r/   c                    s,   t  ttttf td fdd}|S )N)r   backend_indicesr   c                    s6   t |   | |W  d    S 1 s(0    Y  d S r"   r#   )r   r0   r$   r   r   r%   k   s    
z1with_native_function_and_indices.<locals>.wrapper)r&   r'   r   r   r	   r   r   r(   r   r$   r    with_native_function_and_indicesh   s     r1   )Ztorchgen.utilsr   r   r   Ztorchgen.modelr   r   r   r   r	   Ztorchgen.localr    r&   typingr
   r   r   r   r   r   
contextlibr   boolr   contextmanagerr!   r)   r+   r-   r/   r1   r   r   r   r   <module>   sB    

		$	(
(