o
    h	                     @   s   d dl mZmZmZ d dlm  mZ d dlm  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eded	ee fd
dZededed	ee fddZedeeef ded	ee fddZdS )    )ListOptionalUnionN)kernel_signature)with_native_function_and_index)BackendIndexNativeFunctionNativeFunctionsGroup)mapMaybefbackend_indexreturnc                 C   sV   t | |}|| }|d u rd S d|jv rd S |jrdnd}| d|j|jd dS )Nzlegacy::static	TORCH_API )name;)r   
get_kernelkernelexternaldecl)r   r   sigmetadataprefix r   T/var/www/html/ai/venv/lib/python3.10/site-packages/torchgen/dest/native_functions.pygen_unstructured   s   


r   gc                 C   sj   t | }t| }|| }|d u rg S |jrdnd}d| d|j d| dddd	 |D  d
	gS )N z
TORCH_API zstruct structured_z : public at::meta::structured_z {
void impl(z, c                 s   s    | ]}|  V  qd S N)r   ).0ar   r   r   	<genexpr>$   s    z!gen_structured.<locals>.<genexpr>z);
};
)metar   
structuredimpl_argumentsr   r   r   join)r   r   	meta_nameout_argsr   r   r   r   r   gen_structured   s    


r*   c                    sp     | }t| tr*|d ur|jr jrtdt|  S tt fdd| 	 S t
|  }|d u r5g S |gS )Nz>Structured external backend functions are not implemented yet.c                    s
   t |  S r    )r   )r   r   r   r   <lambda><   s   
 z5compute_native_function_declaration.<locals>.<lambda>)r   
isinstancer	   r%   r   AssertionErrorr*   listr
   	functionsr   )r   r   r   xr   r+   r   #compute_native_function_declaration,   s   



r2   )typingr   r   r   torchgen.api.metaapir$   torchgen.api.structuredr%   torchgen.api.typesr   torchgen.contextr   torchgen.modelr   r   r	   torchgen.utilsr
   strr   r*   r2   r   r   r   r   <module>   s&    
