
    Ogc                        d dl mZ d dlmc mZ d dlmc mZ d dlmZ d dl	m
Z
 d dlmZmZmZ d dlmZ ddZe
dd       Ze
dd	       Ze
	 	 	 	 	 	 dd
       Zy)    )annotationsN)kernel_signature)with_native_function_and_index)BackendIndexNativeFunctionNativeFunctionsGroup)mapMaybec                v    | j                   ryddi}|j                  | j                  j                  d      dz   S )N XPUTORCH_XPU_API	TORCH_API )externalgetdispatch_keyname)bankend_index!device_torch_api_key_word_mappings     e/var/www/html/suriana-translation/venv/lib/python3.12/site-packages/torchgen/dest/native_functions.pytorch_api_key_word_prefixr      sM     	)%
 	*--&&++[	
 	    c                    t        | |      }|j                  |       }|y d|j                  v ry |j                  rdnd}| d|j	                  |j                         dS )Nzlegacy::staticr   r   )r   ;)r   
get_kernelkernelr   decl)fbackend_indexsigmetadataprefixs        r   gen_unstructuredr$       sh    
1m
,C''*HX__$*3338889:!<<r   c                    t        j                  |       }t        j                  |       }|j	                  |       }|g S t        |      }d| d|j                   d| ddj                  d |D               d	gS )Nzstruct structured_z : public at::meta::structured_z {
void impl(z, c              3  <   K   | ]  }|j                           y wN)r   ).0as     r   	<genexpr>z!gen_structured.<locals>.<genexpr>8   s     0!QVVX0s   z);
};
)metar   
structuredimpl_argumentsr   r   r   join)gr    	meta_nameout_argsr"   r#   s         r   gen_structuredr3   -   s    		!I((+H''*H	&}5Fx{8??++J9+ V990x00
1 2	 r   c                   j                  |       }t        | t              rW|/|j                  r#j                  rt        d      t        |       S t        t        fd| j                                     S t        |       }|g S |gS )Nz>Structured external backend functions are not implemented yet.c                    t        |       S r(   )r$   )r   r    s    r   <lambda>z5compute_native_function_declaration.<locals>.<lambda>P   s    #3A}#E r   )r   
isinstancer   r-   r   AssertionErrorr3   listr	   	functionsr$   )r0   r    r"   xs    `  r   #compute_native_function_declarationr<   @   s     ''*H!)*H$7$7%%$T  &a77Eq{{}U  Q.Yr'QC'r   )r   r   returnstr)r   r   r    r   r=   z
str | None)r0   r   r    r   r=   	list[str])r0   z%NativeFunctionsGroup | NativeFunctionr    r   r=   r?   )
__future__r   torchgen.api.metaapir,   torchgen.api.structuredr-   torchgen.api.typesr   torchgen.contextr   torchgen.modelr   r   r   torchgen.utilsr	   r   r$   r3   r<    r   r   <module>rI      s|    "     , , / ; M M #*  	=  	=    $  (,(=I((  (r   