o
    hc                     @  s   d dl 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 dddZe
dddZe
dddZe
dddZdS )    )annotationsN)kernel_signature)with_native_function_and_index)BackendIndexNativeFunctionNativeFunctionsGroup)mapMaybebankend_indexr   returnstrc                 C  s&   | j rdS ddi}|| jjdd S )N XPUTORCH_XPU_API	TORCH_API )externalgetdispatch_keyname)r	   !device_torch_api_key_word_mapping r   r/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torchgen/dest/native_functions.pytorch_api_key_word_prefix   s   r   fr   backend_index
str | Nonec                 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::staticr   r   )r   ;)r   
get_kernelkernelr   decl)r   r   sigmetadataprefixr   r   r   gen_unstructured    s   


r$   gr   	list[str]c                 C  sd   t | }t| }|| }|d u rg S t|}d| d|j d| dddd |D  d	gS )	Nz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>8   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    


r2   %NativeFunctionsGroup | NativeFunctionc                   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>P   s   
 z5compute_native_function_declaration.<locals>.<lambda>)r   
isinstancer   r-   r   AssertionErrorr2   listr   	functionsr$   )r%   r   r"   xr   r4   r   #compute_native_function_declaration@   s   



r;   )r	   r   r
   r   )r   r   r   r   r
   r   )r%   r   r   r   r
   r&   )r%   r3   r   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$   r2   r;   r   r   r   r   <module>   s    
