
    Χg                        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Zd#dZd$dZed k    r e             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                   t          t          j                            |d          | |          \  }}t          j                            |d          }t	          | |          j        }	t          t          |j        |	          d           }
t          |
|          }|s8t          || ||||           t          || |||           t          ||	|           t          |||           t          || ||           t          |||           d S )Nderivatives.yaml	templatesc                4    t          j        | j                  S )N)r   namefunc)fs    c/var/www/html/ai-engine/env/lib/python3.11/site-packages/torchgen/packaged/autograd/gen_autograd.py<lambda>zgen_autograd.<locals>.<lambda>G   s    chqv&&     )key)r   ospathjoinr   native_functionssortedfilter(is_native_function_selected_for_trainingr   r   r   r   r   r   r   )r   r   r   r   r   r   differentiability_infosused_dispatch_keystemplate_pathnative_funcsfnsfns_with_diff_infoss               r$   gen_autogradr5   3   sL    3C
\#5668My3 3// GLL{;;M$%:IFFWL
F	
 	
 '&	  C 	%S*ABB 
  9!	
 	
 	
 	!&	3F	
 	
 	

 	sL-888s$;]KKK 3 5y-PPP 3+];;;;;r&   c                <   t          t          j                            |d          | |          \  }}t          j                            |d          }t	          |||           t          j                            |d          }t          j        || |||           d S )Nr   r   zdeprecated.yaml)r   r(   r)   r*   r   r
   gen)r   r   r   r   r/   _r1   deprecated_paths           r$   gen_autograd_pythonr:   h   s     "2
\#5668My" "Q GLL{;;M "#'>NNN gll<1BCCO"I    r&   c                    t          j        d          } |                     ddd           |                     ddd           |                     d	d
d           |                     ddd           |                                 }t	          |j        |j        |j        |j        t          j
                               d S )Nz"Generate autograd C++ files script)descriptionr+   NATIVEzpath to native_functions.yaml)metavarhelptagszpath to tags.yamlr   OUTzpath to output directoryautogradAUTOGRADzpath to autograd directory)argparseArgumentParseradd_argument
parse_argsr5   r+   r@   r   rB   r   get_nop_selector)parserargss     r$   mainrK   ~   s    $1UVVVF
H3R     7JKKK
u3MNNN
J-I     D	)++    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   rD   r(   torchgen.apir   torchgen.api.autogradr   r   torchgen.genr   !torchgen.selective_build.selectorr    r
   gen_autograd_functionsr   r   r   r   r   r   r   r   r5   r:   rK   __name__ r&   r$   <module>rW      s   0 # " " " " "  				              + * * * * * > > > > > > " " " " " "        ? > > > > > * * * * * * : : : : : : 0 0 0 0 0 0 * * * * * * . . . . . . #2< 2< 2< 2< 2<j   ,   ( zDFFFFF r&   