o
    vZh	                     @  s   d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ 	d$d%ddZd&dd Zd'd!d"Zed#krve  dS dS )(a~  
To run this file by hand from the root of the PyTorch
repository, run:

python -m tools.autograd.gen_autograd        aten/src/ATen/native/native_functions.yaml        aten/src/ATen/native/tags.yaml        $OUTPUT_DIR        tools/autograd

Where $OUTPUT_DIR is where you would like the files to be
generated.  In the full build system, OUTPUT_DIR is
torch/csrc/autograd/generated/
    )annotationsN)cpp)match_differentiability_info'NativeFunctionWithDifferentiabilityInfo)parse_native_yaml)SelectiveBuilder   )gen_python_functions)gen_autograd_functions_libgen_autograd_functions_python)gen_inplace_or_view_type)gen_trace_type)gen_variable_factories)gen_variable_type)gen_view_funcs)load_derivativesFnative_functions_pathstr	tags_pathoutautograd_diroperator_selectorr   disable_autogradboolreturnNonec                 C  s   t tj|d| |\}}tj|d}t| |j}	tt|j|	dd d}
t	|
|}|sDt
|| |||| t|| ||| t||	| t||| t|| || t||| d S )Nderivatives.yaml	templatesc                 S  s   t | jS )N)r   namefunc)f r!   V/var/www/auris/lib/python3.10/site-packages/torchgen/packaged/autograd/gen_autograd.py<lambda>G   s    zgen_autograd.<locals>.<lambda>)key)r   ospathjoinr   native_functionssortedfilterZ(is_native_function_selected_for_trainingr   r   r   r   r
   r   r   )r   r   r   r   r   r   differentiability_infosZused_dispatch_keystemplate_pathZnative_funcsfnsZfns_with_diff_infosr!   r!   r"   gen_autograd3   s:   		
r.   c                 C  sX   t tj|d| |\}}tj|d}t||| tj|d}t|| ||| d S )Nr   r   zdeprecated.yaml)r   r%   r&   r'   r   r	   gen)r   r   r   r   r+   _r,   Zdeprecated_pathr!   r!   r"   gen_autograd_pythonh   s   
r1   c                  C  st   t jdd} | jdddd | jdddd | jd	d
dd | jdddd |  }t|j|j|j|jt	
  d S )Nz"Generate autograd C++ files script)descriptionr(   ZNATIVEzpath to native_functions.yaml)metavarhelptagszpath to tags.yamlr   ZOUTzpath to output directoryautogradZAUTOGRADzpath to autograd directory)argparseArgumentParseradd_argument
parse_argsr.   r(   r5   r   r6   r   Zget_nop_selector)parserargsr!   r!   r"   main~   s"   r=   __main__)F)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )
r   r   r   r   r   r   r   r   r   r   )r   r   )__doc__
__future__r   r7   r%   Ztorchgen.apir   Ztorchgen.api.autogradr   r   Ztorchgen.genr   Z!torchgen.selective_build.selectorr    r	   Zgen_autograd_functionsr
   r   r   r   r   r   r   r   r.   r1   r=   __name__r!   r!   r!   r"   <module>   s.    	
5

