
    sg	                        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 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                    t        | |      }|j                  |       }|y d|j                  v ry |j                  rdnd}| d|j	                  |j                         dS )Nzlegacy::static	TORCH_API )name;)r   
get_kernelkernelexternaldecl)fbackend_indexsigmetadataprefixs        Q/var/www/html/venv/lib/python3.12/site-packages/torchgen/dest/native_functions.pygen_unstructuredr      sh    
1m
,C''*HX__$*3338889:!<<    c                    t        j                  |       }t        j                  |       }|j	                  |       }|g S |j
                  rdnd}d| d|j                   d| ddj                  d |D               d		gS )
N z
TORCH_API z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>#   s     0!QVVX0s   z);
};
)metar   
structuredimpl_argumentsr   r   r   join)gr   	meta_nameout_argsr   r   s         r   gen_structuredr+      s    		!I((+H''*H	 ))R|F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>;   s    #3A}#E r   )r   
isinstancer   r%   r   AssertionErrorr+   listr	   	functionsr   )r(   r   r   xs    `  r   #compute_native_function_declarationr4   +   s     ''*H!)*H$7$7%%$T  &a77Eq{{}U  Q.Yr'QC'r   )r   r   r   r   returnz
str | None)r(   r   r   r   r5   	list[str])r(   z%NativeFunctionsGroup | NativeFunctionr   r   r5   r6   )
__future__r   torchgen.api.metaapir$   torchgen.api.structuredr%   torchgen.api.typesr   torchgen.contextr   torchgen.modelr   r   r   torchgen.utilsr	   r   r+   r4    r   r   <module>r@      sw    "     , , / ; M M #  	=  	=    $  (,(=I((  (r   