+
    &j                     a  0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
Ht ^ RIHtHt ^ RIHt ^ RIHtHtHtHt ^ RIHt ^ RIt^ RIHu Ht ^ RIHu Ht ^ RIHu Ht ^ RI Hu H!t! ^ RI"H#t# ^ RI$H%t% ^ R	I&H't' ^ R
I(H)t)H*t*H+t+H,t,H-t-H.t.H/t/ ^ RI0H1t1H2t2H3t3H4t4 ^ RI5H6t6H7t7 ^ RI8H9t9H:t:H;t;H<t<H=t=H>t> ^ RI?H@t@ ^ RIAHBtBHCtCHDtDHEtEHFtFHGtGHHtHHItIHJtJHKtKHLtLHMtMHNtNHOtOHPtPHQtQHRtRHStSHTtTHUtUHVtVHWtWHXtXHYtYHZtZH[t[ ^ RI\H]t]H^t^H_t_H`t` ^ RIaHbtb ^ RIcHdtdHeteHftfHgtgHhthHitiHjtj ^ RIkHltlHmtm ]'       d	   ^ RInHotoHptp ]! R4      tq ! R R]m4      tr]
! RRR.4      ts/ stR]uR&   / svR]uR&   R R  ltwRR" R# lltxRR$ R% llty]P                  R& R' l4       t{RR(R!R)R/R* R+ lllt|R, R- lt}R. R/ lt~R0 R1 ltR2 R3 ltR4 R5 ltR6 R7 ltR8 R9 ltR: R; ltR< R= ltR> R? lt]! R@RA7       ! RB RC4      4       t]! R@RA7       ! RD RE4      4       t]! R@RA7       ! RF RG4      4       t]! R@RA7       ! RH RI4      4       t]! R@RA7       ! RJ RK4      4       t]3RL RM l4       tRN RO ltRP RQ lt]! R@RA7       ! RR RS4      4       tRT RU ltRV RW ltRX RY ltRZ R[ ltR\ R] ltR^ R_ ltR` Ra lt]3Rb Rc l4       tRd Re lt]4Rf Rg l4       tRh Ri ltRj Rk ltRl Rm ltRn]#EP:                  /Ro Rp lltRq Rr ltRn]#EP:                  /Rs Rt lltRu Rv ltRw Rx ltRy Rz ltR{ R| ltR} R~ ltR R ltR R ltR R ltR R ltR R ltR R lt]R8X  d
   ]! 4        R# R# )    )annotationsN)defaultdict
namedtupleOrderedDict)	dataclassfield)Path)AnyLiteralTYPE_CHECKINGTypeVar)assert_never)cpp)	translate)BindingCppSignatureCppSignatureGroupDispatcherSignature
NamedCTypeNativeSignatureSpecialArgName)method_with_native_functionnative_function_managerwith_native_function with_native_function_and_indices)gen_aoti_c_shim_files*gen_static_dispatch_backend_call_signature) gen_functionalization_definition"gen_functionalization_registration.gen_functionalization_view_inverse_declaration,gen_functionalization_view_meta_classes_decl,gen_functionalization_view_meta_classes_implGenCompositeViewCopyKernelgen_all_vmap_plumbing)ArgumentBackendIndexBackendMetadataBaseOperatorNameDEFAULT_KERNEL_NAMESPACEdispatch_device_mapDispatchKeyFRAGMENT_NAMESPACESFunctionSchemais_cuda_dispatch_keyis_generic_dispatch_keyis_ufunc_dispatch_keyis_xpu_dispatch_keyLocationNativeFunctionNativeFunctionsGroupNativeFunctionsViewGroupOperatorNameOptionalType
SchemaKindSelfArgumentSTRUCTURED_DISPATCH_KEYSTensorOptionsArgumentsTypeVariantViewSchemaKind)add_generated_native_functionsgen_composite_functional_kernelgen_composite_out_kernelpre_group_native_functions)SelectiveBuilder)	concatMapcontextFileManagermake_file_managermapMaybeNamespaceHelperTarget)
YamlDumper
YamlLoader)CallableSequenceTc                  ,   a  ] tR t^tRV 3R lltRtV ;t# )
LineLoaderc                	h   < \         SV `  WR 7      pVP                  P                  ^,           VR&   V# ))deep__line__)superconstruct_mapping
start_markline)selfnoderT   mapping	__class__s   &&& d/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torchgen/gen.pyrW   LineLoader.construct_mapping   s3    '+D+<"oo22Q6
     )F)__name__
__module____qualname____firstlineno__rW   __static_attributes____classcell__)r]   s   @r^   rR   rR      s     r`   rR   
ParsedYamlnative_functionsbackend_indiceszdict[str, ParsedYaml]_GLOBAL_PARSE_NATIVE_YAML_CACHEzdict[str, set[str]]_GLOBAL_PARSE_TAGS_YAML_CACHEc               (    V ^8  d   QhRRRRRRRR/# )   dispatch_keyr,   
device_fmsdict[str, FileManager]
default_fmrG   returnra   )formats   "r^   __annotate__ru      s0      &  	r`   c                z   a  VP                  \        V 3R  l\        P                  ! 4        4       R4      V4      pV# )c              3  L   <"   T F  w  rV! S4      '       g   K  Vx  K  	  R # 5iNra   ).0checkdevicero   s   &  r^   	<genexpr>1file_manager_from_dispatch_key.<locals>.<genexpr>   s$      %@ME& %@s   $
$ )getnextr+   items)ro   rp   rr   fms   f&& r^   file_manager_from_dispatch_keyr      sB    
 
%8%>%>%@
 	
 	

B Ir`   Fc               0    V ^8  d   QhRRRRRRRRR	R
RR/# )rn   esobject
valid_tagsset[str]ignore_keysset[DispatchKey] | Nonepathstrskip_native_fns_genboolrs   rh   ra   )rt   s   "r^   ru   ru      sD     1# 1#1#1# )1# 	1#
 1# 1#r`   c           	       aa \        V \        4      '       g   \        R \        V 4       24      h. p\	        \
        4      pV  F  p\        V\
        4      '       g   \        RV 24      h\        VP                  R4      \        4      '       g   \        RV 24      h\        W7R,          4      oVP                  R4      oSf   \        RV 24      h\        VV3R l4      ;_uu_ 4        \        P                  ! VSW4      w  rVP                  V4       \        P                  ! Wi4       RRR4       K  	  \        V4       \	        R 4      p
V'       g   \!        WV4       VP#                  4        F3  w  r\        TR	R
\%        V4      ;'       g    \'        V4      VR7      W&   K5  	  \)        WZ4      #   + '       g   i     EK  ; i)$Expected 'es' to be a list, but got zExpected to be dict: rU   Expected '__line__' to be int: funcNzMissed 'func' in c                    < R S RS  2# zin z:
  ra   )funcslocs   r^   <lambda>*parse_native_yaml_struct.<locals>.<lambda>   s    s3%uUG4r`   c                 >    \        \        P                  R RR/ R7      # )TFro   use_out_as_primaryexternaldevice_guardindex)r'   r,   	Undefinedra   r`   r^   r   r      s     $..# 
r`   TFr   )
isinstancelistAssertionErrortyper   dictr   intr3   rF   r4   	from_yamlappendr'   
grow_indexerror_check_native_functionsr@   r   r/   r2   rh   )r   r   r   r   r   rsbser   mindiceskvr   r   s   &&&&&        @@r^   parse_native_yaml_structr      s    b$CDH:NOO!BALTARB!T"" #8!<==!%%
+S11 #B1#!FGGtz]+f= #4QC!899455$..q#zOGDIIdO##B* 65  !$/:	

0G &r.
!#-a0JJ4G4J

  b""; 655s   *AF44Gc               $    V ^8  d   QhRRRRRR/# )rn   r   r   r   r   rs   r   ra   )rt   s   "r^   ru   ru      s!      v S  r`   c                T  aa \        V \        4      '       g   \        R \        V 4       24      h\	        4       pV  F  p\        VP                  R4      \        4      '       g   \        RV 24      h\        WR,          4      oVP                  R4      o\        VV3R l4      ;_uu_ 4        VP                  4       pVP                  R4      pVP                  RR4      pVR8X  d   \        RV R24      hVP                  V4       R	R	R	4       K  	  V#   + '       g   i     K  ; i)
r   rU   r   tagc                    < R S  RS 2# r   ra   )r   tagss   r^   r   (parse_tags_yaml_struct.<locals>.<lambda>   s    s3%uTF3r`   descr~   zTag 'z#' must have a non-empty descriptionN)r   r   r   r   setr   r   r3   rF   copypopadd)	r   r   r   r   e_inamer   r   r   s	   &&     @@r^   parse_tags_yaml_structr      s    b$CDH:NOO5B!%%
+S11 #B1#!FGGtz]+uuU|344&&(C775>D7762&Drz$uTF2U%VWWFF4L 54  I 544s   -ADD'c                    V ^8  d   QhRRRR/# )rn   r   r   rs   r   ra   )rt   s   "r^   ru   ru      s     / /# /( /r`   c                    V \         9  dY   \        V 4      ;_uu_ 4       p\        P                  ! V\        R 7      p\        W R7      \         V &   RRR4       \         V ,          # \         V ,          #   + '       g   i     \         T ,          # ; i)Loader)r   N)rl   openyamlloadrR   r   )r   fr   s   &  r^   parse_tags_yamlr      sj     00$ZZ11Z0B2H2W)$/  )..(..	 Z )..s   0A11B	r   loaded_yamlc               0    V ^8  d   QhRRRRRRRRRR	R
R/# )rn   r   r   tags_yaml_pathr   r   r   r   r   zobject | Noners   rh   ra   )rt   s   "r^   ru   ru      sD     1 1
11 )1
 1 1 1r`   c                  V \         9  db   \        V4      pVf:   \        V 4      ;_uu_ 4       p\        P                  ! V\
        R7      pR R R 4       MTp\        XVVV VR7      \         V &   \         V ,          #   + '       g   i     L4; i)Nr   )r   r   )rk   r   r   r   r   rR   r   )r   r   r   r   r   r   r   r   s   &&&$$   r^   parse_native_yamlr      s|     22$^4
 dqYYq4  B0H 31
'- +400 s   A::B
	c                    V ^8  d   QhRRRR/# )rn   r   Sequence[NativeFunction]rs   Nonera   )rt   s   "r^   ru   ru     s     = =(@ =T =r`   c           	     L   / p\        \        4      pV  FP  pW1VP                  P                  &   W#P                  P                  P                  ,          P	                  V4       KR  	  V  EF  pVP
                  e   VP                  VP
                  4      pVf=   \        VP                  P                   RVP
                   RVP
                   R24      hVP                  '       g=   \        VP                  P                   RVP
                   RVP
                   R24      h\        \        P                  4      p0 RmpVP                  P                  P                   Fv  pVP                  V9   g   K  \        VP                  P                  4      VP                  3V9  g   KH  \        RVP                   RVP                  P                   R24      h	  RVP                  9   g   EK  \        VP                  P                  4      R	8w  g   EK  \        VP                  P                  4      R
8w  g   EK  \        VP                  P                  P                  4      R8w  g   EK  VP                  P                  P                  pVP                   '       g#   \        VP                  P                   R24      h\#        VP$                  RVP&                  4      p	\)        W),          4      ^ 8X  g   EK  \        VP                  P                   RV R24      h	  R # )Nz0 is marked as a structured_delegate pointing to z, but z is missing.zY is not marked as structured. Consider adding 'structured=True' to the delegated operatorzArgument name 'z' in function 'z' is a reserved Python keyword.inplace_viewresize_
resize_as_set_z is marked with tag: inplace_view, but it doesn't follow the naming convention for inplace ops - the codegen expects the base name to have a trailing underscore.Fzw is marked with tag: inplace_view. The codegen expects there to be a corresponding out-of-place view op with the name 'z.' and matching schema, but it didn't find one.>   zrandom_.fromfromuniform_r   !_has_compatible_shallow_copy_typer   )r   r   r   r   r   structured_delegater   r   
structuredr   keywordkwlist	argumentsflat_allr   r   inplacer)   basedunder_methodlen)
r   func_mapbase_func_mapr   delegate_funcPYTHON_RESERVED_KEYWORDSEXCLUSION_LISTarg	base_nameout_of_place_base_names
   &         r^   r   r     s   35HBMdBSM !ffkk&&'..q1    ,$LL)>)>?M$$vv{{m#S,,-VA4I4I3J,X  !+++$vv{{m#S,,-VA4I4I3J KRS  $'w~~#6 
 66##,,Cxx33$chh/~E()#((?166;;-Ono  - aff$AFFKK I-AFFKK L0AFFKK$$%/((I$$$$vv{{m $t t  &6y'>'>&" =89Q>$vv{{m $;;D+Esu i r`   c                    V ^8  d   QhRRRR/# )rn   sr   rs   ra   )rt   s   "r^   ru   ru   ]  s     
 
# 
# 
r`   c                .   V P                  RR4      p V P                  RR4      p V P                  RR4      p V P                  RR4      p V P                  R	R
4      p V P                  RR4      p V P                  RR4      p V P                  RR4      p RV  R2# )z1Convert a python string into a c++ string literal\z\\"z\"z\az\bz\f
z\nz\v	z\t)replacer   s   &r^   
cpp_stringr   ]  s    			$A			#uA			$A			$A			$A			$A			$A			$Aqc8Or`   c                    V ^8  d   QhRRRR/# )rn   backendslist[BackendIndex]rs   zlist[DispatchKey]ra   )rt   s   "r^   ru   ru   w  s     	
 	
#5 	
:K 	
r`   c                    \        V 4      ^ 8X  d   . # V  Uu. uF  qP                  NK  	  up\        P                  \        P                  \        P
                  \        P                  .,           # u upi )r   )r   ro   r,   CompositeImplicitAutograd%CompositeImplicitAutogradNestedTensorCompositeExplicitAutograd&CompositeExplicitAutogradNonFunctional)r   backends   & r^   static_dispatch_keysr  w  s`    
8}	4<=H$$H=11==11>>	A
 
 	
=s   A1c               $    V ^8  d   QhRRRRRR/# )rn   r   r4   backend_indexr'   rs   zDispatchKey | Nonera   )rt   s   "r^   ru   ru     s$      &2r`   c                x   V P                   f   VP                  V 4      '       d   VP                  # V P                  '       d   \        P
                  # V P                  '       d   \        P                  # V P                  '       d   \        P                  # V P                  '       d   \        P                  # R # rx   )r   
has_kernelro   &has_composite_explicit_autograd_kernelr,   r  5has_composite_explicit_autograd_non_functional_kernelr  &has_composite_implicit_autograd_kernelr   4has_composite_implicit_autograd_nested_tensor_kernelr  )r   r  s   &&r^   get_static_dispatch_backendr    s     	(M,D,DQ,G,G
 )))	
	1	1	1444	
	@	@	@AAA	
	1	1	1444	
	?	?	?@@@r`   c               $    V ^8  d   QhRRRRRR/# )rn   r   r4   r  r   rs   
str | Nonera   )rt   s   "r^   ru   ru     s$      &8r`   c                    Ve   V P                   '       d   R # . pV FD  p\        W4      pVf   K  VP                  RV P                   RVP	                  4        R24       KF  	  RP                  V4      # )N#include <ATen/ops/__dispatch.h>r   )manual_kernel_registrationr  r   	root_namelowerjoin)r   r  outputr   ro   s   &&   r^   static_dispatch_ops_headerr    st      < < <F21<#MM%akk]!L4F4F4H3IV  99Vr`   c                    V ^8  d   QhRRRR/# )rn   r   r   rs   	list[str]ra   )rt   s   "r^   ru   ru     s      ,> 9 r`   c                J    \        V 4       Uu. uF	  pR V R2NK  	  up# u upi )#include <ATen/Functions.h>)r  )r   ro   s   & r^   static_dispatch_extra_headersr     s7     1::L ,|4:  s    c               $    V ^8  d   QhRRRRRR/# )rn   sig"CppSignature | DispatcherSignaturecpp_sigr   rs   r   ra   )rt   s   "r^   ru   ru     s&      ,  ,	+ , , 	 ,r`   c                0   R  R lp\        V P                  4       4      p\        VP                  4       4      pV F6  pVP                  P                  \        P
                  8X  g   K.  V! V4      p M	  \        W44      pRP                  R V 4       4      # )c                    V ^8  d   QhRRRR/# )rn   input_bindingszlist[Binding]rs   ra   )rt   s   "r^   ru   $translate_args.<locals>.__annotate__  s      m  r`   c                8   . pV  F  pVP                   R 8X  dm   \        \        \        P                  VP
                  P                  4      VP                   VP                  VP                  R7      pVP                  V4       K  VP                  V4       K  	  V# )memory_format)nctyper   defaultargument)
r   r   r   r    possibly_redundant_memory_formatr+  r   r,  r-  r   )r'  output_bindingsbindingspl_mem_format_bindings   &   r^   add_spl_memory_format_binding5translate_args.<locals>.add_spl_memory_format_binding  s    )+%G||.)0%&GG++ !#OO$--*&  &&'=>&&w/ & r`   , c              3  8   "   T F  qP                   x  K  	  R # 5irx   exprry   as   & r^   r|   !translate_args.<locals>.<genexpr>  s     +UVVU   )r   r   r+  r   r   r.  r   r  )r"  r$  r2  src_bindingsgoal_bindingsr   exprss   &&     r^   translate_argsr?    s|    
$ (L**,-M ::??nMMM8FL  l2E99+U+++r`   c               (    V ^8  d   QhRRRRRRRR/# )	rn   r"  r#  r   r4   r  r'   rs   r   ra   )rt   s   "r^   ru   ru     s6     R R	+RR  R 		Rr`   c           	     :   \        W4      pVP                  4       p\        W4      pVP                  V4      pV'       d   VP                  '       d   VP                  M\
        pVP                  R R4      pRV RVP                  P                  4        RV RV R2	# )::nativer~   return ::();)	r   r   r?  
get_kernelcpp_namespacer*   r   ro   r  )	r"  r   r  r$  r   r>  backend_metadata	kernel_nsnss	   &&&      r^   %generate_static_dispatch_backend_callrL    s    
 9@G<<>D3(E$//2  0 > > > 	&&% 
 
		:r	*BRD=55;;=>bawbQQr`   c               (    V ^8  d   QhRRRRRRRR/# 	rn   r"  r#  r   r4   rj   r   rs   r   ra   )rt   s   "r^   ru   ru     s6     K K	+KK (K 		Kr`   c                   \         P                  ! VR R R7      pV P                  '       d.   VP                  P	                  4       '       d   VP
                  pMVP                  pVf   \        R4      hVP                  4       p\        W4      p\        P                  ! RR4      pVP                  '       d,   RV R\        P                  P                  4        RV RV R2	# VP                   '       d,   RV R\        P"                  P                  4        RV RV R2	# VP$                  '       d,   RV R\        P&                  P                  4        RV RV R2	# VP(                  '       d,   RV R\        P*                  P                  4        RV RV R2	# R	T R
RP-                  V Uu. uF  p\/        VP0                  4      NK  	  up4       R2# u upi )Fmethodfallback_bindingzExpected cpp_sig to be non-NonerB  r~   rC  rD  rE  rF  z5TORCH_CHECK(false, "Static dispatch does not support z forr4  z ");)r   from_native_functionsymintr   
has_symintsymint_signature	signaturer   r   r?  r*   r   r
  r,   r  r  r  r  r  r   r  r  r  r   ro   )	r"  r   rj   cpp_sigsr$  r   r>  rK  r   s	   &&&      r^   &generate_static_dispatch_fallback_callrY    s   
 !55	%%H zzzaff''))++$$>??<<>D3(E	!	)	)*b	9B///B{DDJJLMRPTvUVW\V]]_``	
	@	@	@B{QQWWYZZ\]a\bbcdicjjlmm	
	1	1	1B{DDJJLMRPTvUVW\V]]_``	
	?	?	?B{PPVVXYY[\`[aabchbiikllH OAC""#AB C4K 	KAs   -Gc               (    V ^8  d   QhRRRRRRRR/# rN  ra   )rt   s   "r^   ru   ru     s6     F F	+FF (F 		Fr`   c           	        \        V4      ^ 8X  g   VP                  '       d   R# V Uu. uFC  pVP                  V4      '       g(   VP                  f   K*  VP                  \
        9   g   KA  VNKE  	  pp\        V4      ^8X  d   \        WV^ ,          4      # \        V4      ^ 8X  d   \        WV4      # V P                  4        Uu. uF}  p\        VP                  \        4      '       gO   \        VP                  \        4      '       g   KE  VP                  P                  P                  4       '       g   Kq  VP                  NK  	  ppRP!                  V4      pVP"                  P                  P$                  p. p	. p
Ve   V
P'                  R4       VR8w  d   V
P'                  RV R24       V	P'                  RRP!                  V
4       R24       V	P'                  R	4       . pV FA  pVP'                  R
VP                   R24       VP'                  R\        WV4       R24       KC  	  \        WV4      pRpRVP!                  V	4       RVP!                  V4       RV R2# u upi u upi )a  
For a given `NativeFunction`, find out the corresponding backend and dispatch to it. If more than one
backends exist, fallback to static dispatch by determining dispatch key from inputs.
Arguments:
    sig: A CppSignature or DispatcherSignature for this native function we want to use.
    f: NativeFunction to generate static dispatch.
    backend_indices: All available backends.
Return:
    C++ code to call backend-specific functions, e.g., "return at::cpu::add(self, other, scale);"
r~   r4  z>DispatchKeySet(c10::computeDispatchKey(dtype, layout, device))z$c10::detail::multi_dispatch_key_set()zDispatchKeySet _dk_set = z | ;z=DispatchKey _dk = c10::highestPriorityBackendTypeId(_dk_set);zcase DispatchKey:::r   z
		
    z
    switch (_dk) {
        z
        default:
            z
    }
    )r   r  r	  r   ro   r;   rL  rY  r   r   r-  r:   r&   r   is_tensor_liker   r  r   tensor_optionsr   )r"  r   rj   bkeysr9  native_tensor_argstensor_argstensor_optsstmtssubexprsdispatch_coder   fallback	connectors   &&&            r^   static_dispatchrl    sM    ?q A$@$@$@ ! A<<??!!	 	

 ":: 	
  	  4yA~4ST!WEE	Ta5coNN  Aajj,//ajj(+ 	 JJOO**,	 	    ))./K&&""11KEHL	
 b>{m1MN	LL.uzz(/C.DAHI	LLPQM!3E4F4F3GqKL8GHL	
  6coNHI^^E 			&' (J  [s*   I&I&I&,I&AI+'I+8I+T)frozenc                  T    ] tR tRt$ R]R&   ]! ]R7      tR]R&   ]R R l4       t	R	t
R
# )RegisterSchemaiP  rD   selector)default_factoryzdict[str, int]
known_tagsc                    V ^8  d   QhRRRR/# rn   r   r4   rs   r  ra   )rt   s   "r^   ru   RegisterSchema.__annotate__V  s     ` `. `Z `r`   c                	   V P                   P                  V4      '       g   R # RRP                  R \        VP                  4       4       4      ,           R,           pVR8X  d#   R\        \        VP                  4      4       R2# RpW P                  9  d-   \        V P                  4      pW@P                  V&   R	V R
V R2pV R\        \        VP                  4      4       RV P                  V,           R2# )N{r4  c              3  ,   "   T F
  pR V 2x  K  	  R# 5i)z	at::Tag::Nra   )ry   r   s   & r^   r|   *RegisterSchema.__call__.<locals>.<genexpr>Y  s     KNS3%0Ns   }z{}zm.def(z, {});
r~   z const std::vector<at::Tag> tags_z = ;
z, tags_z);
)
rp  is_native_function_selectedr  sortedr   r   r   r   rr  r   )rZ   r   r   
maybe_tagsidxs   &&   r^   __call__RegisterSchema.__call__U  s    }}88;;TYYKF166NKKKcQ4<Js166{34J??
&doo&C$'OOD!;C5D6MJVJs166{$;#<GDOOTXDYCZZ^__r`   ra   N)rb   rc   rd   re   __annotations__r   r   rr  r   r  rf   ra   r`   r^   ro  ro  P  s+    !&t!<J< ` !`r`   ro  c                  B    ] tR tRt$ R]R&   R]R&   ]R R l4       tRtR	# )
ComputeOperatorsii  .Literal[Target.DECLARATION, Target.DEFINITION]targetr   static_dispatch_backend_indicesc                    V ^8  d   QhRRRR/# rn   r   r4   rs   r   ra   )rt   s   "r^   ru   ComputeOperators.__annotate__o  s     R& R&. R&S R&r`   c                	   \         P                  ! VP                  4      pVP                  P                  P	                  4       pV P
                  \        P                  J d   R V RVP                  4        RVP                  P                  P                   RVP                  P                  P                   R\        \        VP                  4      4       RVP                  RRR7       RVP                  R	R
R7       R2# V P
                  \        P                  J Ed-   RVP                   RV RV RV RV RV R2pR EF  pV'       dD   RP                  R.VP                  4        Uu. uF  qfP                  NK  	  up,           4      pR	pM:RP                  VP                  4        Uu. uF  qfP                  NK  	  up4      pRpTp	V RV 2p
RV RV	 RV R2pV'       g2   \!        V P"                  4      ^ 8  d   \%        W!V P"                  R7      pVRVP                   RVP                  WR7       RV R2,          pEK  	  V# \'        V P
                  4       R# u upi u upi ) z
struct TORCH_API z {
  using schema = z;
  using ptr_schema = schema*;
  // See Note [static constexpr char* members for windows NVCC]
  static constexpr const char* name = "aten::z3";
  static constexpr const char* overload_name = "z/";
  static constexpr const char* schema_str = z;
  static callF)r   is_redispatching_fn
redispatchTz;
};

// aten::z.
static C10_NOINLINE c10::TypedOperatorHandle<z::schema> create_zQ_typed_handle() {
  return c10::Dispatcher::singleton()
      .findSchemaOrThrow(z::name, z::overload_name)
      .typed<z::schema>();
}
r4  dispatchKeySetrD  z
    static auto op = create_z_typed_handle();
    return op.rE  rF  )rj   r    {
    z
}
N)FT)r   from_schemar   r   unambiguous_namer  rK   DECLARATIONr   overload_namer   r   defn
DEFINITIONr  r   r   r  rl  r   )rZ   r   r"  r   defnsr  r9  dispatcher_exprs_strmethod_basedispatcher_callmethod_namefn_bodys   &&          r^   r  ComputeOperators.__call__n  s   !--aff5vv{{++-;;&,,,0 ((* . /0ffkk.>.>-? @1121J1J0K L--7AFF-D,E F

((E(
:	; <

(($(
?	@ A
 
 [[F---

&& ..2V3DTF Kxv .V E (5#&+/99)*cmmo-Noffo-NN,( #/K+/99cmmo5Voffo5V+W("(K"-!%b6!F #q!5 6b<
 ,D@@AAE .0T0TG  

&& {D E FI  3 (5> L%= .O 6Ws   .I%/I*
ra   Nrb   rc   rd   re   r  r   r  rf   ra   r`   r^   r  r  i  s"    ::%77 R& !R&r`   r  c                  ,    ] tR tRt]R R l4       tRtR# )ComputeFunctioni  c                    V ^8  d   QhRRRR/# rt  ra   )rt   s   "r^   ru   ComputeFunction.__annotate__  s     ( (. (Z (r`   c                	V   \         P                  ! VR VP                  R7      pVP                  P	                  4       pRpVP                  4        EFO  p\        P                  ! VP                  4      p\        VP                  4       VP                  4       4      pRP                  V Uu. uF  qP                  NK  	  up4      p	VP                  '       d   Rp
MRp
\        P                  VP                  9   dQ   VRVP                   RVP!                  4        RVP                  P"                  P%                  4        R	V	 R
2	,          pV'       g   EK  VRV
 RVP!                  RR7       RVP                  P"                  P%                  4        R	V	 R2	,          pEKR  	  V# u upi )FrP  r~   r4  zc10::SymIntint64_tr  
inline  {
    return at::_ops::::call(z);
}zZ
namespace symint {
  template <typename T, typename = std::enable_if_t<std::is_same_v<T, z>>>
  T)suppress_symint_suffixz	);
  }
}
)r   rS  manual_cpp_bindingr   rU  
signaturesr   r  r   r   r  r7  rT  r>   functionvariantsdeclr   r  )rZ   r   	sig_grouprU  resultr"  
target_sigr>  r   	exprs_str	intlike_ts   &&         r^   r  ComputeFunction.__call__  s   %::ea.B.B
	 VV&&(
'')C,88@Jcmmoz/C/C/EFE		5"95a665"9:Izzz)	%	1::- 

&& 
| ffkk2245WYK H  z GGPk R8848() *ffkk2245WYK H	 3 *B ; #:s   +F&
ra   Nrb   rc   rd   re   r   r  rf   ra   r`   r^   r  r    s     ( !(r`   r  c                  B    ] tR tRt$ R]R&   R]R&   ]R R l4       tRtR	# )
ComputeTensorMethodi  r  r  r   r  c                    V ^8  d   QhRRRR/# rt  ra   )rt   s   "r^   ru    ComputeTensorMethod.__annotate__  s     $ $. $Z $r`   c                	D   \         P                  VP                  9  d   R # VP                  P	                  4       '       d   \        RVP                   24      hVP                  P                  P                  f   \        RVP                   24      h\        P                  ! VRVP                  R7      pV P                  \        P                  J d5   RpVP                  4        F  pW4P                  4        R2,          pK  	  V# V P                  \        P                   Jd   \#        V P                  4       RpVP                  4        F  p\$        P&                  ! VP                  4      p\)        VP                  4       VP                  4       RR7      pRP+                  V Uu. uF  qwP,                  NK  	  up4      pVR	VP                   R
VP/                  RR7       RVP                  P0                  P3                  4        RV R2	,          pK  	  V# u upi )Nz*Method variant cannot be an out function: z#Method variant must have self_arg: TrP  r~   z const;
)rQ  r4  r  r  zTensor::)prefixz const {
    return at::_ops::r  );
}
)r>   rQ  r  r   	is_out_fnr   r   self_argr   rS  r  r  rK   r  r  r  r  r   r   r  r   r  r7  r  r   r  )	rZ   r   r  r  r"  r  r>  r   r  s	   &&       r^   r  ComputeTensorMethod.__call__  s   >>+66 #MaffX!VWW66$$, #Fqvvh!OPP%::dQ-A-A
	 ;;&,,,F ++-XXZL	22 .M;;f///%'')C,88@Jcmmoz/C/C/EdSE		5"95a665"9:I 

&& 
#$ %ffkk2245WYK H F *  #:s   *H
ra   Nr  ra   r`   r^   r  r    s     ::%77 $ !$r`   r  c                  ,    ] tR tRt]R R l4       tRtR# )ComputeRedispatchFunctioni&  c                    V ^8  d   QhRRRR/# rt  ra   )rt   s   "r^   ru   &ComputeRedispatchFunction.__annotate__)  s      . Z r`   c                	    \         P                  ! VR VP                  R7      pRpVP                  4        F  p\        P
                  ! VP                  4      p\        VP                  4       VP                  4       4      pRP                  R.V Uu. uF  qwP                  NK  	  up,           4      pVRVP                   RVP                  RR7       R	VP                  P                  P                  4        R
V R2	,          pK  	  V# u upi )FrP  r~   r4  r  r  r  T)r  r  z::redispatch(r  )r   rS  r  r  r   r  r   r   r   r  r7  r  r   r  )	rZ   r   r  r  r"  r  r>  r9  r  s	   &&       r^   r  "ComputeRedispatchFunction.__call__(  s     &::ea.B.B
	 '')C,88@Jcmmoz/C/C/EFE		#3"47N17N"NOI 

&& T*+ ,ffkk2245]9+ N F *  8Os   Dra   Nr  ra   r`   r^   r  r  &  s      !r`   r  c                    V ^8  d   QhRRRR/# r  ra   )rt   s   "r^   ru   ru   F  s     M M~ M# Mr`   c                    R V P                   P                  P                   RV P                   P                  P                   R2# )z{"aten::z", "z"},)r   r   r  r   s   &r^   compute_aten_opr  E  s5    qvv{{''(QVV[[-F-F,GtLLr`   c                    V ^8  d   QhRRRR/# )rn   gr5   rs   r  ra   )rt   s   "r^   ru   ru   K  s     y y)= y* yr`   c                   V P                   '       g   R # \        V P                  4      ;_uu_ 4        \        P                  ! V 4      p\         P
                  ! V 4      pRP                  R V 4       4      pV P                  P                  pVf   RpRpV P                   '       d   V P                  P                  MR pV'       Edo   . VP                  P                  4       OVP                  NpV UU	u. uF  q F  qNK  	  K  	  p
pp	V
 U	u. uF  qP                  P                  4       NK  	  pp	RP                  R V 4       4      pRV R2pV
 U	u. uF$  p	\         P                  ! WP                  R7      NK&  	  pp	R	P                  R
 V 4       4      p. p\        V
4       EFD  w  pp	RP                  VR V R.,           VV^,           R  ,           4      pRV R2pVV,          P                  RR7      pV RV	P                   RV R2pRV	P                   R2pRVV,           RV R2p. pVP!                  V R24       \        V
4       FZ  w  pp	VV8X  d"   VP!                  RV	P                   R24       K.  VP!                  RV	P                   RV	P                   R24       K\  	  VP!                  R4       RP                  V4      pVP!                  RV RV R V R!24       EKG  	  RP                  V4      pRP                  R.\#        V4      ,          4      pR"V R#2pR$pR%V R&V RV R'2pMR(pR(pR)V R*V R+V R,V R,V R-V R.2uuR R R 4       # u up	pi u up	i u up	i   + '       g   i     R # ; i)/Nr4  c              3  @   "   T F  qP                  4       x  K  	  R # 5irx   )r  r8  s   & r^   r|   4compute_meta_function_declaration.<locals>.<genexpr>Q  s     4t!VVXXt   zat::impl::MetaBasevoidc              3  .   "   T F  pR V R2x  K  	  R# 5i)zbool z = falseNra   )ry   params   & r^   r|   r  c  s      85TE%wh'5Ts   z
template <>)bindsr{  c              3  d   "   T F&  pVP                  R R7       RVP                   2x  K(  	  R# 5i)T	strip_ref N)cpp_typer   )ry   elems   & r^   r|   r  n  s2      3?D ==4=01499+>?s   .0truezprecompute_out<Tr  z set_rE  z value)r   z already set"zstatic_assert(z == false, rF  z ret;zret.z	 = value;z	 = this->r]  zreturn ret;r   z
                    z {
                        z
                        z'
                    }
                z'using meta_return_ty = precompute_out <z>;meta_return_tyz
                zG
                struct TORCH_API precompute_out {
                    z;
            };r~   zstruct TORCH_API structured_z
 : public r  r_  z meta(z);
};
)r   r   outmetar   meta_argumentsr  structured_inheritsprecomputedr   valuesr   upperargument_type	enumerater  r   r   )r  r   argsargs_strparent_classmeta_returnr  precomputed_valuesreplace_listr  precomputed_elementsprecomputed_template_parametersprecomputed_template_params_strprecompute_template_decl#precomputed_elements_with_cpp_typesprecomputed_elements_declsetter_methodsireturn_ty_templates	return_tyelem_cpp_tyrW  
assert_msgassert_stmtconstruction_stmtsjconstruction_blocksetter_methods_declmeta_return_template_paramsmeta_return_typedefprecomputed_decls   &                              r^   !compute_meta_function_declarationr   K  s   <<<	 	'	'yy|((+994t44uu00/L+,<<<aee''T; "R;#6#6#=#=#?!Q!Q);$);); ! $ /C/.Bd		!.B , / /3ii 85T8 /+ *44S3TTU'V$
 130D ((YY?0 0 3
 ).

 3?3 )%  N$%9:4 '+ii3BQ7h5a!eg>?'#
 ..A-B!D	A!DMM" N   )ktyyk;-wO	  !=9
 ./Nq/Q.RR]^h]iikl &(""))YKu*=>()=>GAtAv*11D92MN*11"499+YtyykC	  ? #))-8%)YY/A%B"%%K  $ &+, -W ;f #'))N"; +/))3>??+'
 %LLgKhhj"k*K$)* +() *./ 0	  #%!!F*\N ;  Mz "	a 
(	'$/37 
(	'	'sC   A4M)' M)-M)5M
M)"M0$M)*M$>GM)M))M:	c               $    V ^8  d   QhRRRRRR/# )rn   r   r4   rp  rD   rs   r   ra   )rt   s   "r^   ru   ru     s"     3 3N 36F 34 3r`   c                   \        V P                  P                  P                  4      pVP                  R 4      '       g   VP	                  R4      '       d   R# V P                  P
                  P                  f   R# VP                  V 4      # )_likenew_F)r   r   r   endswith
startswithr   ra  r|  )r   rp  r   s   && r^   needs_backend_selectr    sd    qvv{{ D}}W!8!8vv&&.//22r`   c                  B    ] tR tRt$ R]R&   R]R&   ]R R l4       tRtR	# )
ComputeBackendSelecti  z/Literal[Target.DEFINITION, Target.REGISTRATION]r  rD   rp  c                    V ^8  d   QhRRRR/# rt  ra   )rt   s   "r^   ru   !ComputeBackendSelect.__annotate__  s     8& 8&. 8&Z 8&r`   c                	   \        WP                  4      '       g   R # \        P                  ! VP                  4      p\        VP                  RR7      pVP                  4        Uu. uFS  p\        VP                  \        4      '       g   K%  VP                  P                  P                  4       '       g   KQ  VNKU  	  pp\        P                  ! VP                  4      pTpVP                  4       pRp	V P                  \         P"                  J Ed   V'       de   VP                  P                  P%                  4       '       g   \'        RVP                   24      hRP)                  R V 4       4      p
RV	 RV
 R	2pMHVP                  P                  P%                  4       '       d   \'        R
VP                   24      hRV	 R2pRVP                   RVP+                  V4       RV RVP                  P                  P-                  4        RRP)                  R V 4       4       R2# V P                  \         P.                  J d   RVP                  P                   RV R2# \1        V P                  4       R # u upi )NTrT  z.c10::computeDispatchKey(dtype, layout, device)z'Expected function to have tensor args: r4  c              3  8   "   T F  qP                   x  K  	  R # 5irx   r   r8  s   & r^   r|   0ComputeBackendSelect.__call__.<locals>.<genexpr>  s     'K8J18Jr;  z-DispatchKeySet _dk_set = c10::DispatchKeySet(z() | c10::detail::multi_dispatch_key_set(z);
DispatchKeySet _dk_mask = c10::DispatchKeySet(DispatchKeySet::FULL_AFTER, DispatchKey::BackendSelect);
DispatchKeySet _dk = c10::impl::computeDispatchKeySet(_dk_set, _dk_mask);z+Expected function to not have tensor args: z)DispatchKeySet _dk = c10::DispatchKeySet(rF  z	// aten::z
C10_ALWAYS_INLINE
z {
  z
  return at::_ops::z::redispatch(
      _dk, c              3  8   "   T F  qP                   x  K  	  R # 5irx   r6  r8  s   & r^   r|   r    s     7&6ff&6r;  r  zm.impl("aten::z", TORCH_FN(z));)r  rp  nativer   r   r   r   r   r-  r&   r   r`  r   r  r>  r  rK   r  has_tensor_argr   r  r  r  REGISTRATIONr   )rZ   r   r   
native_sigr9  rd  dispatcher_sigr"  dispatcher_exprsro   re  
compute_dks   &&          r^   r  ComputeBackendSelect.__call__  s=   #A}}55{{166"$QVVD9
  ))+
+!**h/ 45JJOO4R4R4T A+ 	 
 -88@ )//1G;;&+++
 "vv''6688(A!&&J  #ii'K8J'KK"..:^;cdocp qJM

 66##2244(EaffXN  @~RP 

&& $  , FFKK0023 4II7&6778 9  [[F///%affkk],tfCJJ%a
s   '"I>'I>:I>ra   Nr  ra   r`   r^   r	  r	    s"    ;;  8& !8&r`   r	  c                    V ^8  d   QhRRRR/# )rn   datar   rs   r   ra   )rt   s   "r^   ru   ru     s     S Sf S Sr`   c                    R  \         n        R R lp\         P                  ! \        V4       \        P
                  ! V R\         RR7      # )c                    R # )Tra   )rZ   r  s   &&r^   r   format_yaml.<locals>.<lambda>   s    4r`   c               $    V ^8  d   QhRRRRRR/# )rn   dumperr
   r  rs   ra   )rt   s   "r^   ru   !format_yaml.<locals>.__annotate__#  s!     3 3 3C 3C 3r`   c                @    V P                  VP                  4       4      # rx   )represent_dictr   )r   r  s   &&r^   dict_representer%format_yaml.<locals>.dict_representer#  s    $$TZZ\22r`   Fg    eA)default_flow_styleDumperwidth)rL   ignore_aliasesadd_representerr   r   dump)r  r$  s   & r^   format_yamlr,    s9     7J3 {,<= 99TeJcRRr`   c                    V ^8  d   QhRRRR/# )rn   r   r   rs   r   ra   )rt   s   "r^   ru   ru   1  s        r`   c                    V R 8X  d   R# V R8X  d   R#  \        V 4      #   \         d%     \        T 4      u #   \         d    T u u # i ; ii ; i)r  TfalseF)r   
ValueErrorfloatr   s   &r^   pythonify_defaultr2  1  sU    F{	
g1v 	8O 	H	s)   
 A
8AA
A	A

Ac                    V ^8  d   QhRRRR/# )rn   tr=   rs   r   ra   )rt   s   "r^   ru   ru   I  s     
 
D 
S 
r`   c                    \        V \        4      '       d   \        V P                  4      # \	        V 4      R 8X  d   R# \
        P                  ! V RRRR7      P                  4       # )Tensorz
at::TensorF__placeholder__)mutabler  rT  )r   r8   dynamic_typer  r   r   argumenttype_typer  )r4  s   &r^   r9  r9  I  sS    !\""AFF## 1v  	5 1%hjr`   c                    V ^8  d   QhRRRR/# )rn   r  zset[Variant]rs   r  ra   )rt   s   "r^   ru   ru   V  s      \ i r`   c                    R .p\         P                  V 9   d   VP                  R4       \         P                  V 9   d   VP                  R4       V# )r=   r6  	namespace)r>   rQ  r   r  )r  	method_ofs   & r^   compute_method_of_yamlr?  V  sG     I~~!"8#%r`   c                    V ^8  d   QhRRRR/# )rn   r   r4   rs   z+tuple[list[dict[str, str]], dict[str, str]]ra   )rt   s   "r^   ru   ru   a  s     ?' ?'?'0?'r`   c                B   / p\         P                  ! V 4      p. p\        \        V P                  P
                  V4      4       F  w  pw  rVR \        VP                  4      RVR\         P                  ! VRR7      P                  4       /pVP                  '       dm   VP                  VR&   V P                  P                  4       '       d>   VP                  WP                  P                  P                  V,          P                  &   VP                  V4       K  	  W13# )r9  r   r   Fr  
field_name)r   return_namesr  zipr   returnsr9  r   return_typer  r   r  r   r  r   )r   name_to_field_namenamesrE  r  rr   rets   &       r^   compute_returns_yamlrK  a  s    T *, QEG!#affnne"<=9AL0DCOOAe4==?	
 666 !Cvv!!CD66"66#3#3#7#7#:#?#?@s >  &&r`   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )rn   cpp_ar   schema_orderr   kwarg_only_setr   out_arg_setrG  dict[str, str]rs   r   ra   )rt   s   "r^   ru   ru     sF     
 

 
 	

 
 '
 
r`   c                  \        V P                  \        4      '       dB   R RRRRRRV P                  RV P                  RR	/pV P
                  e   V P
                  VR
&   V# \        V P                  \        4      '       d   \        h\        V P                  \        4      '       d   \        V P                  VVVVR7      # R# )
annotationNr9  zat::TensorOptionsis_nullableFr   r   
kwarg_onlyTr,  rN  rO  rP  rG  )
r   r-  r<   r   r   r,  r:   r   r&   compute_argument_yaml)rM  rN  rO  rP  rG  r   s   &$$$$ r^   compute_cpp_argument_yamlrX    s     %.."899$/5EJJEJJ$"
 ==$"]]C	N
	ENNL	1	1	ENNH	-	-$NN%)#1
 	
 
.r`   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )rn   r9  r&   rN  r   rO  r   rP  rG  rQ  rs   r   ra   )rt   s   "r^   ru   ru     sF     ! !! ! 	!
 ! '! !r`   c                  R V P                   '       d   \        V P                   4      MRR\        V P                  4      RV P                  P	                  4       RV P
                  R\        P                  ! V RRR7      P                  4       /pV P                  e:   \        \        P                  ! V P                  V P                  RR	7      4      VR
&   V P
                  V9   d   RVR&   V P
                  V9   d1   RVR&   RVR&   V P
                  V9   d   W@P
                  ,          VR&   V P                  P                  4       pVe8   VP                  e*   \        VP                  4      R8w  d   VP                  VR&   V# )rS  Nr9  rT  r   r   r7  F)r  rT  r  r,  TrU  r  allocaterB  r   size)rS  r   r9  r   rT  r   r   r  r  r,  r2  default_expris_list_liker\  r  )r9  rN  rO  rP  rG  r   ls   &$$$$  r^   rW  rW    s5    	1<<<c!,,'TQVV,qvv))+!!!+<UKTTVC 	yy*QYYu=
I 	vv LvvHJ66'' 266 :C 	
A}+AFFv0EffFJr`   c                    V ^8  d   QhRRRR/# )rn   r   r4   rs   r   ra   )rt   s   "r^   ru   ru     s     U U U6 Ur`   c                   \        V 4      w  rV P                  P                  P                   Uu0 uF  q3P                  kK  	  ppV P                  P                  P
                   Uu0 uF  q3P                  kK  	  pp\        P                  ! V R R R7      pVP                  P                  4       pV Uu. uF  p\        VR VVVR7      NK  	  p	p\        V P                  P                  4       4      p
V
 Uu. uF  p\        VRVVVR7      NK  	  ppV
 UUu. uF:  p\        P                  ! VR \        4       R R R R7       F  pVP                   NK  	  K<  	  ppp\        P"                  ! V P                  P$                  R R7      P'                  4       pV RRP)                  V4       R2p\*        ;QJ d    R	 V 4       F  '       g   K   RM	  R M! R	 V 4       4      ;'       d    \,        P.                  V P0                  9  p\3        R
\        P                  ! V P                  4      3R\5        V P                  P                  P                  4      3R\5        V P                  P                  P6                  4      3RV P8                  3RV P:                  e   V P:                  MR3RRV P                   23RV	3RV3RV3R\=        V P0                  4      3RRV P>                  f   RMV P>                  3RV3RV P                  P                  P                  P@                  3RV3RV PB                  3RV PD                  3RRRV PF                  3.4      # u upi u upi u upi u upi u uppi ) FrP  rV  T)rQ  cpp_no_default_argsfaithfulrT  has_tensor_optionsr  z (r4  r\  c              3  V   "   T F  p\        VP                  \        4      x  K!  	  R # 5irx   )r   r-  r<   r8  s   & r^   r|   +compute_declaration_yaml.<locals>.<genexpr>   s     MHqJqzz#9::Hs   ')r   operator_namer  r  category_overrider~   schema_stringaten::r   schema_order_cpp_signatureschema_order_argumentsr>  python_modulerE  r   is_factory_methodabstractr   has_math_kernel)moder  )with_gilF)
deprecatedF)$rK  r   r   flat_kwarg_onlyr   r  r   rS  rW  rX  r   rl  rW  r   r-  r   r   returns_typerE  r  r  anyr>   rQ  r  r   r   r  r  rh  r?  rm  r   is_abstractr   r  )r   rE  rG  r9  rO  rP  r  cpp_argsrM  r   schema_order_jit_argumentsrl  rI  cpp_schema_order_typescpp_returnsrk  rn  s   &                r^   compute_declaration_yamlr|    sK   "6q"9G '(ff&6&6&F&FG&Fff&FNG#$66#3#3#7#78#7a66#7K8!66	%%I "",,.H 	 E 	")#1	
   	 "&aff&C&C&E!F ,	 ,A 	)#1	
 ,  	 , ,A #$
A 	

 	+   ""166>>%@IIKK$/=499=S3T2UUV!W 	MHMMHMM 	- 	-NN!**, 
 SXXaff%&c!&&++"2"234c!&&++";";<=)1+G+GH#'(':':'F##B qvvh/0)$)+EF%'=>0<=AOO$;bQ ((001 "34'Q^^,! H HI/	
 m H8		s   M(M5M7M$A M)c                    V ^8  d   QhRRRR/# )rn   r   r4   rs   r   ra   )rt   s   "r^   ru   ru   B  s      . T r`   c                   V P                   ;'       g    V P                  R J;'       d_    V P                  P                  4       \        P
                  8H  ;'       g,    V P                  P                  4       \        P                  8H  # rx   )r   r   r   kindr9   
functionalr   r  s   &r^   "has_autogenerated_composite_kernelr  B  s`    LL==A11=  	...UU!&&++-:CUCU2Ur`   c               $    V ^8  d   QhRRRRRR/# )rn   r   r4   rj   dict[DispatchKey, BackendIndex]rs   r   ra   )rt   s   "r^   ru   ru   I  s$      (Gr`   c                l   \         P                  ! V P                  4      p\         P                  ! V P                  P                  4      P                  4       p\         P                  ! V P                  4      pR P                  R V 4       4      pRRV P                   2R\        VP                  4        UUu0 uF   w  rgVP                  V 4      '       g   K  VkK"  	  upp\        P                  08g  ;'       d_    VP                  4        UUu0 uF   w  rgVP                  V 4      '       g   K  VkK"  	  upp\        P                  \        P                  08g  4      R\        V P                  ;'       g    \        V 4      4      /pV RV RV R\         P"                  ! V4       R	2# u uppi u uppi )
r4  c              3  \   "   T F"  qP                  4       P                  4       x  K$  	  R # 5irx   )
no_defaultr  r8  s   & r^   r|   4compute_registration_declarations.<locals>.<genexpr>O  s      =1,,..   *,schemarj  dispatchr,  r  rE  z); // r   )
dispatcherr   r   ru  rE  r  r   r  r   r   r	  r,   r   r  has_composite_kernelr  jsondumps)	r   rj   r   ru  r  r  r   r   comment_datas	   &&       r^   !compute_registration_declarationsr  H  sj    ??166"D**166>>:CCEL'Dyy===HF166(#C*002F241all1oQQ2F5567  .446J6tq!,,q/6J55AA
 	3q--VV1STU1VW$L ~QtfAhZvdjj6N5O P   GJs   9F*F*F00F0c               $    V ^8  d   QhRRRRRR/# )rn   "provided_op_registration_allowlistzlist[str] | Noneop_selection_yaml_pathr  rs   rD   ra   )rt   s   "r^   ru   ru   i  s&      (8& r`   c                    V e   Ve   \        R4      hR pV e   \        V 4      pVe   \        P                  ! VRR4      pV# Ve   \        P                  ! V4      pV# \        P
                  ! 4       pV# )NzhBoth provided_op_registration_allowlist and op_selection_yaml_path can NOT be provided at the same time.TF)r   r   rD   &from_legacy_op_registration_allow_listfrom_yaml_pathget_nop_selector)r  r  op_registration_allowlistrp  s   &&  r^   get_custom_build_selectorr  i  s    
 	+6".4
 	

 26)5$'(J$K! ,#JJ%
 O 
 	+#223IJ O $446Or`   c                    V ^8  d   QhRRRR/# )rn   ri   r   rs   z3Sequence[NativeFunction | NativeFunctionsViewGroup]ra   )rt   s   "r^   ru   ru     s      0O 0O.0O80Or`   c                "   R  R lp\        \        4      pV  F  pVP                  P                  4       pVP                  pV\
        P                  8X  dZ   VP                  P                  4       pWbV,          9   d&   \        RV RW$,          P                  4        24      hW2V,          V&   K  WRV,          9   d%   \        V RW$,          P                  4        24      hW2V,          V&   K  	  \        \        WP                  4       4      4      # )c                    V ^8  d   QhRRRR/# )rn   dz1dict[ViewSchemaKind | SchemaKind, NativeFunction]rs   z/list[NativeFunction | NativeFunctionsViewGroup]ra   )rt   s   "r^   ru   :get_grouped_by_view_native_functions.<locals>.__annotate__  s      <	8r`   c                j   . p\         P                  V 9   d}   V P                  \         P                  4      pV P                  \         P                  R 4      pV P                  \        P
                  R 4      pVP                  \        VVVR7      4       VP                  V P                  4       4       V# )N)view	view_copyview_inplace)
r?   aliasingr   aliasing_inplacer9   r  r   r6   extendr  )r  r   r  r  r  s   &    r^   maybe_create_view_groupEget_grouped_by_view_native_functions.<locals>.maybe_create_view_group  s     BD""a'55001D55!@!@$GLj33T:ILL('!- 	QXXZ r`   zDuplicate schema kind z in z already in )r   r   r   view_signatureview_schema_kindr?   non_aliasingr  r   rc  r   rE   r  )ri   r  grouped_by_viewsr   r  	view_kindr  s   &      r^   $get_grouped_by_view_native_functionsr    s   . 	D  &&($%$6$6	
 33366;;=D//$,TF$7G7O7T7T7V6WX  ./V$T*V44$ k.>.F.K.K.M-NO  34V$Y/' * 	13J3J3LMNNr`   c                    V ^8  d   QhRRRR/# )rn   ri   r   rs   /Sequence[NativeFunction | NativeFunctionsGroup]ra   )rt   s   "r^   ru   ru     s      .4r`   c           	     |    R  R lp\        V 4      p\        \        V\        VP                  4       4      4      4      # )c                    V ^8  d   QhRRRR/# )rn   r  z dict[SchemaKind, NativeFunction]rs   r  ra   )rt   s   "r^   ru   2get_grouped_native_functions.<locals>.__annotate__  s      +	8r`   c                d   \         P                  ! V 4      pVf   \        ;QJ d*    R V P                  4        4       F  '       g   K   RM	  RM! R V P                  4        4       4      '       d&   \	        R\        V P                  4       4       24      h\        V P                  4       4      # V.# )Nc              3  @   "   T F  pR VP                   9   x  K  	  R# 5i)	generatedN)r   ry   r   s   & r^   r|   Jget_grouped_native_functions.<locals>.flatten_pre_group.<locals>.<genexpr>  s     =*Q;!&&(*r  TFzVGenerated NativeFunctions should have been grouped into NativeFunctionsGroup objects: )r5   	from_dictrv  r  r   r   )r  rI  s   & r^   flatten_pre_group7get_grouped_native_functions.<locals>.flatten_pre_group  s     !**1-9 s=!((*=sss=!((*===$559!((*5E4FH  
##3Jr`   )rC   r   rE   r  )ri   r  pre_grouped_native_functionss   &  r^   get_grouped_native_functionsr    s<    " $>>N#O #T*F*M*M*O%PQ r`   native_function_decl_genc               (    V ^8  d   QhRRRRRRRR/# )	rn   grouped_native_functionsr  rj   r  r  JCallable[[NativeFunctionsGroup | NativeFunction, BackendIndex], list[str]]rs   dict[str, list[str]]ra   )rt   s   "r^   ru   ru     s2      M 5	 r`   c                   \        \        4      pV  F  p\        4       p\        4       pVP                  4        F  w  rxVP	                  V4      p	V	'       d0   V	P
                  p
VP                  V4       VP                  V
4       M\        p
\        V4      ^8  d   \        RV RV 24      hW:,          P                  V! WH4      4       K  	  K  	  V# )   z6Codegen only supports one namespace per operator, got z from )r   r   r   r   rG  rH  r   r*   r   r   r  )r  rj   r  ns_grouped_kernelsr   native_function_namespacesdispatch_keysro   backend_idxrI  r=  s   $$$        r^   get_ns_grouped_kernelsr    s     0;4/@%%(U")8)>)>)@%L*55a8,::	!!,/*..y94	-.2$56f]OM  )00(8 *A && r`   c                    V ^8  d   QhRRRR/# )rn   r  r  rs   r  ra   )rt   s   "r^   ru   ru     s      , r`   c           
     4   . pR pV P                  4        F  w  r4\        VR^R7      p\        \        P                  ! V4      4      pVP                  R VP                   R VP                  V4       R VP                   R2P                  V4      4       K  	  V# )r   r~   namespace_strentity_name	max_level	
        )
r   rJ   r   r   fromkeysr  prologuer  epiloguesplit)r  declarationsnewliner=  kernels	ns_helperordered_kernelss   $      r^   8get_native_function_declarations_from_ns_grouped_kernelsr    s     !LG0668	##
	 {33G<=
  o   
  	 E'N	
 9  r`   c               (    V ^8  d   QhRRRRRRRR/# )	rn   r  r  rj   r  r  r  rs   r  ra   )rt   s   "r^   ru   ru     s2      M 5	 r`   c                6    \        V VVR7      p\        VR7      # )a  
Generate kernel declarations, in `NativeFunction(s).h`.
:param grouped_native_functions: a sequence of `NativeFunction` or `NativeFunctionGroup`.
:param backend_indices: kernel collections grouped by dispatch key.
:param native_function_decl_gen: callable to generate kernel declaration for each `NativeFunction`.
:return: a list of string, from the string with all declarations, grouped by namespaces, split by newline.
r  rj   r  )r  )r  r  )r  rj   r  r  s   $$$ r^    get_native_function_declarationsr    s+      0!9'!9
 D- r`   c               $    V ^8  d   QhRRRRRR/# )rn   r   %NativeFunction | NativeFunctionsGroupr  r'   rs   r   ra   )rt   s   "r^   ru   ru   (  s$      
/>Jr`   c           	     t   VP                  V 4      pV'       d   R VP                  9  dv   \        V \        4      '       d   V P                  P
                  MV P                  P                  P
                  p\        RV RVP                   RVP                   R24      hV'       d   VP                  # \        # )rB  zThe kernel for function z with dispatch key z has a namespace z% and it's not ending with '::native'.)
rG  rH  r   r4   r   r   r  r   ro   r*   )r   r  rI  	func_names   $$  r^   get_kernel_namespacer  (  s     #--a0J.>.L.LL%a88AFFKKall>O>O>T>T 	 &yk 2!!,!9!9 : ;/==>>ce
 	
 +;&&@Xr`   c               @    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRR/
# )rn   r   rG   r  r  ro   r,   r  r'   rp  rD   rocmr   rT  skip_dispatcher_op_registrationgen_dispatch_helpersrs   r  ra   )rt   s   "r^   ru   ru   <  s{     _ __ N_ 	_
 _ _ _ _ &*_ _ _r`   c        	          aaaaaaa . p	\        \        4      o\        \        4      o\        \        4      p
R p\        P                  ! V\
        P                  VVVRSR7      p\        P                  ! V\
        P                  VVVRSR7      p\        P                  ! V\
        P                  VVVRSR7      pV F  p\        WR7      P                  RR4      oSS,          P                  V! V4      4       SS,          P                  V! V4      4       \        V\        4      '       d   VP                  MVP                  P                  pVV
S,          9  d   \        \        4      V
S&   V
S,          V,          P                  V! V4      4       K  	  S F  o\!        SS,          4      ^ 8X  d   K  \#        SR7      oRoV
S,           FK  pV
S,          V,          '       g   K  SRV RS R	VP%                  V
S,          V,          4       R
2,          oKM  	  V	P                  V P'                  RVVVVVVV3R l4      P)                  V4      4       K  	  V	# )r   Nr  rT  class_method_namer  r   r  rB  r~   )r  z
TORCH_LIBRARY_IMPL(r4  z, m) {
    z
}zRegisterDispatchDefinitions.inic                    < R SP                   RSP                  RS S,          RS'       d   RMSRRRSP                  4       RSS,          /# )ns_prologuens_epiloguedispatch_anonymous_definitions"static_init_dispatch_registrationsr~   deferred_dispatch_registrationsdispatch_namespacedispatch_namespaced_definitions)r  r  r  )anonymous_definitionsro   kernel_namespacens_definitionsr  registration_bodyr  s   r^   r   1get_native_function_definitions.<locals>.<lambda>  sZ    !9#5#5!9#5#546K(7 96 ;=*5r(,*<*<*>5~FV7Wr`   )r   r   r   destRegisterDispatchKeyrK   NAMESPACED_DEFINITIONANONYMOUS_DEFINITIONr  r  r   r  r   r4   r=  r  r   rJ   r  substitute_with_templater  )r   r  ro   r  rp  r  rT  r  r  definitionsregistrationsr  ns_genanonymous_genreg_genr   r=  r  r  r  r  r  s   $$d$$$$d$        @@@@@r^   get_native_function_definitionsr  <  sX     K+6t+<N2=d2C5@5FMG%%$$(GF ,,##(GM &&(GG &/!MUU
 	'(//1I	
 	./66!	
 &a88AKKall>T>T 	 M*:;;.9$.?M*+&'	299AJ	
! &( +~./0A5#2BC	&'788I !129== &;b /\\- 01)<=> ?"  9 	''1  eGn!	
 +> r`   c               4    V ^8  d   QhRRRRRRRRR	R
RR
RR/# )rn   r  r  ro   r,   r  r'   rp  rD   r  r   rT  rs   r  ra   )rt   s   "r^   ru   ru     sP     , ,M, , 	,
 , , , ,r`   c           
     l   . p\        \        4      pR p\        P                  ! V\        P
                  VVRRVR7      p	V  FJ  p
\        WR7      P                  RVP                  4       4      pW{,          P                  V	! V
4      4       KL  	  VP                  4        F  w  r\        V4      ^ 8X  d   K  \        VR^R7      p\        \        P                  ! V4      4      pVP                  R VP                   R VP!                  V4       R VP"                   R2P%                  V4      4       K  	  V# )	r   NF)r  r  r  rT  r  r  r~   r  r  )r   r   r  r  rK   NAMESPACED_DECLARATIONr  r   r  r  r   r   rJ   r   r  r  r  r  r  )r  ro   r  rp  r  rT  r  r  r  r   r   r=  r  r  r  s   $$$$$$         r^   get_namespaced_declarationr    s=    !L/:4/@G##%%(-D &(1FNNl((*
	 	%,,G	
 & 1668	w<1##q
	 {33G<=
  o   
  	 E'N	
 9 r`   c               $    V ^8  d   QhRRRRRR/# )rn   ri   r   schema_selectorrD   rs   ztuple[list[str], str]ra   )rt   s   "r^   ru   ru     s(     != !=.!= &!= 	!=r`   c           
     t   \        \        4      pV  F$  pW#P                  ,          P                  V4       K&  	  R p. pRpVP	                  4        Fc  w  rx\        \        \        V4      V4      4      p	VR8X  d   T	pK.  TpRp
V\        9   d   RMRpVRV RV RV
P                  V	4       R	2,          pKe  	  WT3# )
r~   Natenr   TORCH_LIBRARY_FRAGMENTTORCH_LIBRARYr   rE  z	, m) {
  z
};)	r   r   r=  r   r   rI   ro  r-   r  )ri   r  ns_native_functionsnative_functionschema_registrationsaten_schema_registrationscustom_namespacer=  r   schema_registrations_bodytabtorch_library_macros   $$          r^   (get_native_function_schema_registrationsr    s    
 <Gt;L+556==oN , "/557	$(^O4e<%
!
 (A%(C
  33 )$  
 ! ) Q'( )88%&' (%  % 8, &<<r`   c               H    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRRRRRR/# )rn   ri   r   r  r  structured_native_functionsSequence[NativeFunctionsGroup]static_dispatch_idxr   rp  rD   rj   r  cpu_fmrG   rp   rq   functions_keysset[DispatchKey]r  Sequence[DispatchKey]r  r   rs   r   ra   )rt   s   "r^   ru   ru     s     v v.v Nv "@	v
 ,v v 5v v 'v %v )v v 
vr`   c           
       a aaaaaa
aaaaa VP                  R V3R l4       S  Uu. uF&  p\        P                  VP                  9   g   K$  VNK(  	  upoS  Uu. uF  qS9  g   K  VNK  	  upoVP                  RVV3R l4       VP                  RVV3R l4       VP                  RV V3R l4       \	        SSR7      oVP                  R	V3R
 l4       V	 FV  o\        SWv4      pSV9   d@   RS R2oVP                  S R2RVV3R l4       VP                  S R2RVVVV
V3R l4       ?KX  	  R# u upi u upi )zNativeMetaFunctions.hc            	     >   < R . R\        \        \        S 4      4      /# )NativeMetaFunctions_includes NativeMetaFunctions_declarationsr   rI   r   )r  s   r^   r   (gen_aggregated_headers.<locals>.<lambda>  s#    *B.:<WX1
r`   MethodOperators.hc                 h   < R . R\        \        \        \        P                  SR7      S 4      4      /# )MethodOperators_includesMethodOperators_declarationsr  r   rI   r  rK   r  )method_native_functionsr  s   r^   r   r#    s8    &*D$**8K ,-
r`   zOperators.hc                 j   < R R.R\        \        \        \        P                  SR7      S 4      4      /# )Operators_includesz!#include <ATen/MethodOperators.h>Operators_declarationsr(  r)  )non_method_native_functionsr  s   r^   r   r#  $  s<     #F"G$d$**8K 0'
r`   Functions.hc                 ^   < R \        S4      RR.R\        \        \        4       S 4      4      /# )r   Functions_includesz#include <ATen/Operators.h>Functions_declarations)r   r   rI   r  ri   r  s   r^   r   r#  3  s<    +-J#. !#@"A$d#%$'
r`   )r  rj   zNativeFunctions.hc                    < R R.RS /# )NativeFunctions_includesz%#include <ATen/NativeMetaFunctions.h>NativeFunctions_declarationsra   )r  s   r^   r   r#  F  s    &)P(Q*L
r`   r  Functions_inl.h>DispatchKeyFunctions.hc                 "   < R \        S 4      RS/# ro   inline_headersr   ro   inl_headerss   r^   r   r#  T  s    "C$5$kr`   Functions_inl.hDispatchKeyFunctions_inl.hc                 \   < R . RSP                  4       R\        SSS S,          SSRR7      /# )!DispatchKeyFunctions_inl_includesr   dispatch_namespaced_declarationsT)r  ro   r  rp  r  rT  )r  r  )rj   ro   r  r  rp  s   r^   r   r#  \  s=    7(,*<*<*>68R1I%1$3L$A!)!#9r`   N)writer>   rQ  r  r  r   write_with_template)ri   r  r  r  rp  rj   r  rp   r  r  r  fnr   r  ro   r>  r*  r.  s   dddddd$$$$d  @@@@@r^   gen_aggregated_headersrG    s]     LL	
 &%r2;;)F% &#%r3J)J%# LL	
 LL	
 LL	
 4!9'L LL	
 &+L*M>)+L>9IJK"".,( "".0, " = &#s   !D6D6D;'D;c               H    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRRRRRR/# )rn   ri   r   r  r  r  r   rp  rD   rj   r  r  rG   rp   rq   ops_fmr  r  r  r  r  r   rs   r   ra   )rt   s   "r^   ru   ru   m  s      . N ,	
  5  '  % )  
r`   c                  aaaaaaaaaaaaa \        \        4      oV  F%  pSVP                  ,          P                  V4       K'  	  \        \        4      pV F'  pVP                  oVS,          P                  V4       K)  	  SP	                  4        F  w  ooVP                  S R 2RVV3R l4       VP                  S R2RVVV3R l4       VP                  S. 4      pV Uu. uF1  p\        V\        4      '       g   K  VP                  '       g   K/  VNK3  	  upo\        S4      ^ 8  oS'       d   VP                  S R2RV3R l4       \        VV\        P                  R	7      oVP                  S R
2RVVV3R l4       K  	  R  F!  w  ooVP                  S R2VVV3R l4       K#  	  V	 EF  oSV9  d   K  SP                  4       o. oSP	                  4        F  w  ooVP                  S. 4      p\        \!        \        P"                  ! VS,          \$        P&                  VV
RRRR7      V4      4      o\        S4      ^ 8X  d   Ko  SP                  S4       VP                  S RS R2RVV3R l4       K  	  \)        SWe4      pRS R2oVP                  S R2RVV3R l4       VP                  S R2RVV3R l4       ?EK  	  VP                  RV3R l4       R# u upi )!z_ops.hz
Operator.hc            
     d   < R \        \        \        \        P                  SR7      S 4      4      /# )r  r(  r)  )	functionsr  s   r^   r   *gen_per_operator_headers.<locals>.<lambda>  s3    ("..<O "!
r`   z.hz
Function.hc                    < R \        \        V3R lS 4      4      RRS R2R\        \        \        4       S 4      4      /# )static_dispatch_ops_headersc                   < \        V SR 7      # ))r  )r  rF  r  s   &r^   r   <gen_per_operator_headers.<locals>.<lambda>.<locals>.<lambda>  s    #=.A$r`   operator_includesr  _ops.h>function_definitions)r   rI   r  )rL  r   r  s   r^   r   rM    sP    -t "	0 $':4&%H&')!)r`   z_meta.hzNativeMetaFunction.hc                 :   < R \        \        \        S 4      4      /# )meta_function_declarationsr"  )structured_functionss   r^   r   rM    s     0$ =?S3r`   r  z	_native.hzNativeFunction.hc                 2   < R S'       d
   RS R2RS /# . RS /# )extra_includesr  z_meta.h>native_function_declarationsra   )r  is_structuredr   s   r^   r   rM    s,     <I)$x8.	OQ.	r`   c                    < S R 2\        SP                  4       4       U u. uF  p RV  S R2NK  	  up S R2. /# u up i )	_includesr  .h>_declarations)r}  rc  )r   categoryfunctions_by_root_namesuffixs    r^   r   rM    s\    *I& &'='B'B'D E) E *$xs; E) *M*B)s   ;TNFr  r  z_dispatch.hzDispatchKeyFunction.hc                    < R SRS /# )r  rC  ra   )r  r  s   r^   r   rM    s    (*<6r`   r  r7  r/  r8  c                 "   < R \        S 4      RS/# r:  r<  r=  s   r^   r   rM    s    L 1 +r`   r?  r@  c                 ^   < R SR\        S4       U u. uF  p RV  RS R2NK  	  up R. /# u up i )r  rB  r  r  r  rC  )r}  )r   dispatch_namesr  s    r^   r   rM    sN    $&83 &~ 66 6 *$q1C0DLQ 66 3B6s   *
r$  c                 L   < R \        R S P                  4        4       4      R. /# )r&  c              3     "   T FI  w  r\         ;QJ d    R  V 4       F  '       g   K   RM	  RM! R  V 4       4      '       g   KA  RV R2x  KK  	  R# 5i)c              3  \   "   T F"  p\         P                  VP                  9   x  K$  	  R # 5irx   )r>   rQ  r  )ry   rF  s   & r^   r|   Ggen_per_operator_headers.<locals>.<lambda>.<locals>.<genexpr>.<genexpr>(  s     Iyw~~4yr  TFr  rT  N)rv  )ry   r   rL  s   &  r^   r|   =gen_per_operator_headers.<locals>.<lambda>.<locals>.<genexpr>%  sC      /'EOD3IyI333IyII 4%dV73'Es   #AAAr'  )r}  r   )rb  s   r^   r   rM  $  s/    & /'='C'C'E/ )
 +B
r`   ))	Functionsr~   )	Operators_ops)NativeMetaFunctions_meta)NativeFunctions_native)r   r   r  r   r   rE  r   r   r5   r   r   r  r  #compute_native_function_declarationrD  r  rE   r  rK   r  r   )ri   r  r  rp  rj   r  rp   rI  r  r  r  rF  grouped_functions_by_root_namegroupgrouped_functionsr   ra  r  ro   rg  r  rL  rb  r>  r\  r   rX  rc  s   $$d$$$$$$$$     @@@@@@@@@@@@r^   gen_per_operator_headersrx  m  s     ?J$>Or||,33B7 
 	D # *&t,33E: * 2779i""fFO
	
  	""fBK	
, ;>>tRH ( 
'"23 8: B' 

 01A5&&& &
 8%6+%)%M%M

 	""fI		
A :V& 	jO		
" &~-)//15;;=OD) > B B4 L,,'555 !#*.8= &L < A%!!$'&&&,-[9'+  >< ,L*M'~5EF
nK($	
 	nO,(	
 y &| LL	

e 
s   'K-K-K-c          "     \    V ^8  d   Qh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RRRRRRRR/# )rn   ri   r   r   r   r  r  r  r  r  r   rp  rD   rj   r  headeronly_fmrG   core_fmr  rp   rq   rI  r  r  r  r  r  r   per_operator_headersrs   r   ra   )rt   s   "r^   ru   ru   /  s     H5 H5.H5 H5 N	H5
 "@H5 ,H5 H5 5H5 H5 H5 H5 'H5 H5 )H5 %H5  !H5" #H5$ 
%H5r`   c                  a aaa V'       d   \        S VSVSV	V
VVVVR 7       M\        S VVSVSV	V
VVVR7       VP                  RV V3R l4       V	P                  RV 3R l4       V	P                  RVV 3R l4       V	P                  RV 3R	 l4       R
 V 3R llpVP                  RV4       R V3R llpVP                  RV4       R# ))ri   r  r  rp  rj   r  rp   rI  r  r  r  )ri   r  r  r  rp  rj   r  rp   r  r  r  zTensorBody.hc                    < R \        \        \        \        P                  SR7      S 4      4      R\        \        \        \        P
                  SR7      S 4      4      /# )tensor_method_declarations)r  r  tensor_method_definitions)r   rI   r  rK   r  r  r3  s   r^   r   gen_headers.<locals>.<lambda>a  s`    ($'%118K %+ ('%008K %*
r`   zRedispatchFunctions.hc                 B   < R \        \        \        4       S 4      4      /# )function_redispatch_definitions)r   rI   r  ri   s   r^   r   r  y  s!    -t246FG0
r`   zRegistrationDeclarations.hc                 J   < R S U u. uF  p \        V S4      NK  	  up /# u up i )registration_declarations)r  )r   rj   ri   s    r^   r   r    s2    ')*)A 2!_E)*
*s    zVmapGeneratedPlumbing.hc                    < \        S 4      # rx   r$   r  s   r^   r   r    s    +@AQ+Rr`   c                   V ^8  d   QhRR/# rn   rs   rQ  ra   )rt   s   "r^   ru   !gen_headers.<locals>.__annotate__  s     "
 "
~ "
r`   c                 f  < \        4       p \        4       pS F  pVP                  \        VP                  P                  P                  4      4       VP                  VP                  P                  P                  P
                  4       V P                  R  VP                  P                  4        4       4       K  	  V0 Rm,          pRRP                  \        V4       Uu. uF	  pRV R2NK  	  up4      RRP                  \        V 4       Uu. uF	  pRV R2NK  	  up4      /# u upi u upi )c              3  8   "   T F  qP                   x  K  	  R # 5irx   r  )ry   r   s   & r^   r|   Agen_headers.<locals>.gen_aten_interned_strings.<locals>.<genexpr>  s     P-Oc-Or;  aten_symbolsz \
z_(aten, r\  attr_symbolsz_(attr, >   orandnotxorbitorcomplor_eqand_eqbitandnot_eqxor_eq)
r   r   r   r   r   r   updaterl  r  r}  )attrsrH  r   r   ri   s       r^   gen_aten_interned_strings.gen_headers.<locals>.gen_aten_interned_strings  s    %$DIIc$))..--./ IIdiinn))../LLPTYY-M-M-OPP % 	 
 	
 GLL06u>8D6#> GLL06u>8D6#>	
 	
> ?s   $D)
D.zaten_interned_strings.hc                   V ^8  d   QhRR/# r  ra   )rt   s   "r^   ru   r    s     H H> Hr`   c                 <   < R RP                  \        S 4      4      /# )enum_of_valid_tagsz,
)r  r}  )r   s   r^   gen_tags_enum"gen_headers.<locals>.gen_tags_enum  s    $uzz&2D'EGGr`   z
enum_tag.hN)rx  rG  rD  )ri   r   r  r  r  rp  rj   rz  r{  r  rp   rI  r  r  r  r|  r  r  s   dd$$d$d$$$$$$$$$  r^   gen_headersr  /  s    &  -%= 3+!')	
 	-%=(C 3+!')	
 MM	
0 LL	
 LL$	
 LL!#R"
 "
H MM+-FGH H m4r`   c          ,     p    V ^8  d   Qh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RRRRRRRRRRRRR R!R"RR#R$/# )%rn   ri   r   r  r  r  r  view_groupsz"Sequence[NativeFunctionsViewGroup]rp  rD   r  r   rj   r  aoti_fmrG   r{  
cpu_vec_fmr  rp   rq   r  r  r  r  r  r   force_schema_registrationr|  r  update_aoti_c_shimaoti_backendszset[DispatchKey | None]extend_aoti_c_shimrs   r   ra   )rt   s   "r^   ru   ru     s     p p.p Np "@	p
 4p p ,p 5p p p p p 'p )p %p  !p"  $#p$ %p& &*'p( )p* ++p, -p. 
/pr`   c                z	  a aaaaaaaaaa"a#a$a%a&a'a(a)a*a+a,a-a. R pS'       d   RpV EF|  o%\        S%W4      o'V'       d   R V#V%V&VV3R llpM
R V%V3R llpSS%,          o#\        \        4      pS FS  p\        V\        4      '       d   VP
                  MVP                  P
                  pVV,          P                  V4       KU  	  \        S%4      P                  4       o&S%\        P                  8g  o)R\        S%4      '       d   TMRRRR	\        P                  ! S#VS4      R
V! 4       RS)'       d   \        P                  ! S#4      M. /pR V#V%V'V)VVV3R llpS'P!                  RS% R2RSR TS%\        P"                  8X  d   ^M^VR0R7       S EF
  o(S(P$                  P&                  '       d   \)        S%4      '       g   K3  S(P                  P*                  P,                  P,                  o+S%\        P"                  J dM   S'V
Jd   \/        R4      hS'P1                  RS+ R2RVV%V(3R l4       V	P1                  RS+ R2RV(V+3R l4       K  S%\        P2                  J d.   Ro$S'       d   Ro$S'P1                  RS+ R2RVV$V%V(V+3R  l4       K  \/        R!S% R"24      h	  >'EK  	  \5        VVS SSVVVR#7       R$ V V3R% llpV
P7                  R&V4       SpV'       d   \8        P:                  ! 4       p\=        S VR'7      w  o"o,V
P7                  R(V"V,V3R) l4       R* R+ lpV
P?                  R,S VV3R- lR.\A        S4      /^0 RFmR/7       V
P7                  R0\B        4       VP7                  R1\B        4       VP7                  R2V 3R3 l4       R4 R5 lo*R6 VV*V3R7 llp\        S4      \        S4      ,           p \E        R8 S4       U!u/ uF  p!V!P*                  P,                  V!bK  	  up!o-\E        R9 S4       U!u/ uF  p!V!P*                  P,                  V!bK  	  up!o.V PG                  V-V.3R: lS  4       4       V
P?                  R;V VV^0 RGmR<7       V
P7                  R=VV3R> l4       V
P7                  R?VV3R@ l4       V
P7                  RAV*VV3RB l4       V
P7                  RCVVV3RD l4       RE# u up!i u up!i )Hz#include <c10/cuda/CUDAGuard.h>
#include <ATen/cuda/ATenCUDAGeneral.h>
#include <ATen/cuda/CUDADevice.h>
#include <ATen/cuda/CUDAContext.h>z#include <c10/hip/HIPGuard.h>
#include <ATen/hip/ATenHIPGeneral.h>
#include <ATen/hip/HIPDevice.h>
#include <ATen/hip/HIPContext.h>c                   V ^8  d   QhRR/# rn   rs   r  ra   )rt   s   "r^   ru   &gen_source_files.<locals>.__annotate__  s     &, &,i &,r`   c                   < . p S EFW  pR pSP                  V4      '       d   RpM\        V\        4      '       d`   \        ;QJ d-    V3R lVP	                  4        4       F  '       g   K   RM"	  R M! V3R lVP	                  4        4       4      '       d   RpM9VP
                  '       d(   S\        P                  \        P                  39   d   RpV'       g   K  V P                  RVP                   R24       S\        P                  8X  d    V P                  RVP                   R24       SS9   g   EK5  V P                  RVP                   RS R24       EKZ  	  \        \        V 4      4      # )FTc              3  F   <"   T F  pSP                  V4      x  K  	  R # 5irx   )r	  )ry   rF  r  s   & r^   r|   =gen_source_files.<locals>.operator_headers.<locals>.<genexpr>  s#      E?L0044}s   !r  
_native.h>r_  r  r  )r	  r   r5   rv  rL  r   r,   Metar  r   r  r}  r   )headersr  is_registeredr  ro   r  r  r  s      r^   operator_headers*gen_source_files.<locals>.operator_headers  sB   1A$)M$//22(, $A';<< E?@{{}E E?@{{}E B B )- ,#((#JJ; + )-( NN%8Z#PQ$&MMN  )<Q[[M'MN#~51!++a@R?SS_`A 2H c'l++r`   c                   V ^8  d   QhRR/# r  ra   )rt   s   "r^   ru   r  	  s      i r`   c                    < R .p S\         P                  8X  d   V P                  R4       SS9   d   V P                  RS: R24       V # )z!#include <ATen/NativeFunctions.h>z#include <ATen/Functions.h>r  r  )r,   r  r   )r  ro   r  s    r^   r  r  	  sI    >?;#U#UUNN#@A>1NN_\4DL#QRr`   extra_cuda_headersr~   external_backend_headersdispatch_headersops_headersdispatch_helpersc                    V ^8  d   QhRRRR/# )rn   gnfr  rs   r  ra   )rt   s   "r^   ru   r  7	  s     	 	6	!	r`   c                2   < R \        SV .SSSSRSSR7	      /# )dispatch_definitionsT)	r   r  ro   r  rp  r  rT  r  r  )r  )r  r  ro   r   r  r  rp  r  s   &r^   "register_dispatch_key_env_callable<gen_source_files.<locals>.register_dispatch_key_env_callable7	  s7     '(G.1U!- -%4S)=
) r`   Registerz.cppzRegisterDispatchKey.cppc                    V P                   # rx   r  )xs   &r^   r   "gen_source_files.<locals>.<lambda>L	  s    Q[[r`   r  )key_fnenv_callable
num_shardsbase_envsharded_keysz,Expected fm to be cpu_fm for DispatchKey.CPU	UfuncCPU_zUfuncCPU.cppc                    < R \        S4      R\        P                  ! SS S,          4      R\        P                  ! S4      /# )meta_declarationnative_declarationnative_definitions)r   r  rt  compute_ufunc_cpu)rj   ro   r  s   r^   r   r  ]	  s?    *,Ma,P,d.V.V|</ -d.D.DQ.Gr`   UfuncCPUKernel_zUfuncCPUKernel.cppc                 8   < R SR\         P                  ! S 4      /# )r   r  )r  compute_ufunc_cpu_kernel)r  r   s   r^   r   r  h	  s    ,d.K.KA.Nr`   z%#include <ATen/native/cuda/Loops.cuh>z$#include <ATen/native/hip/Loops.cuh>
UfuncCUDA_z.cuzUfuncCUDA.cuc                    < R SRSR\        S4      R\        P                  ! SS S,          4      R\        P                  ! S4      /# )r   cuda_headersr  r  r  )r   r  rt  compute_ufunc_cuda)rj   r  ro   r  r   s   r^   r   r  t	  sI    &*,Ma,P,d.V.V|</ -d.E.Ea.Hr`   zunrecognized z
 for ufunc)r  r  ri   rj   r  r  r  r  c                   V ^8  d   QhRR/# )rn   rs   r  ra   )rt   s   "r^   ru   r  	  s     
 
 4 
r`   c                 Z  < S U u. uF  p \        V S4      '       g   K  V NK  	  pp R V U u. uF  p RV P                   R2NK  	  up R\        \        \	        \
        P                  S4      V4      4      R\        \        \	        \
        P                  S4      V4      4      /# u up i u up i )r  r  rT  !backend_select_method_definitions%backend_select_function_registrations)r  r  r   rI   r	  rK   r  r  )rF  relevant_fnsri   rp  s     r^   gen_backend_select,gen_source_files.<locals>.gen_backend_select	  s    )
)2-A"h-OBB) 	 
 FRFR%bll^7;l 0():):HE|2
 4T()<)<hG6
 	

s   B#B#B(zRegisterBackendSelect.cpp)ri   r  zRegisterSchema.cppc                 :   < R S'       d   . MS RS'       d   . /# S/# )r  r  ra   )r  r  r  s   r^   r   r  	  s+    '. *,*". %'	
 &
r`   c                    V ^8  d   QhRRRR/# )rn   rF  @NativeFunction | NativeFunctionsGroup | NativeFunctionsViewGrouprs   r   ra   )rt   s   "r^   ru   r  	  s      L	r`   c                    V P                   # rx   r  )rF  s   &r^   key_func"gen_source_files.<locals>.key_func	  s     ||r`   zOperators.cppc                n   < R RV P                    R2.R\        \        P                  SR7      ! V 4      ./# )r  r  r_  r  r(  )r  r  rK   r  rQ  s   &r^   r   r  	  sD    #6r||nC!H I %%4G !
r`   r   )r  r  r  r  r  zFunctions.cppzTensorMethods.cppzATenOpList.cppc                 :   < R \        \        \        S 4      4      /# )aten_ops)r   rI   r  r  s   r^   r   r  	  s    Xo7GHI
r`   c                    V ^8  d   QhRRRR/# )rn   r  r  rs   r  ra   )rt   s   "r^   ru   r  	  s     % %K%	%r`   c                   \        V \        4      '       d   R V P                  P                   R2R V P                  P                   R2.pV P                  e<   VR V P                  P                   R2R V P                  P                   R2.,          pV# \        V \
        4      '       d   R V P                  P                   R2R V P                  P                   R2R V P                  P                   R2R V P                  P                   R2.pV P                  e<   VR V P                  P                   R2R V P                  P                   R2.,          pV P                  e<   VR V P                  P                   R2R V P                  P                   R2.,          pV# R V P                   R2R V P                   R2.# )r  r  rT  )
r   r6   r  r  r  r5   r  r  r   r8  )r  r  s   & r^   gen_op_headers(gen_source_files.<locals>.gen_op_headers	  s    a122 &aff&6&6%7zB%aff&6&6%7w?G {{&)!++*?*?)@
K)!++*?*?)@H  N/00%all&<&<%=ZH%all&<&<%=WE%aeeoo%6jA%aeeoo%6g>	G yy$)!))*=*=)>jI)!))*=*=)>gF  yy$)!))*=*=)>jI)!))*=*=)>gF  N &akk]*=%akk]': r`   c                    V ^8  d   QhRRRR/# )rn   r  r  rs   r  ra   )rt   s   "r^   ru   r  
  s     
 
K
	
r`   c                t   < R S! V 4      R\        SV 4      R\        SV S\        P                  ,          4      /# )r  func_definitionsfunc_registrations)r   r   r,   r   )r  rj   r  rp  s   &r^   functionalization_env_callable8gen_source_files.<locals>.functionalization_env_callable
  sK     >!, @! !"D E EF#
 	
r`   c                4    \        V P                  4       4      # rx   r   rL  r  s   &r^   r   r  (
  s    T!++-%8r`   c                4    \        V P                  4       4      # rx   r  r  s   &r^   r   r  +
  s    D4Gr`   c              3     <"   T FA  pVP                   P                  S9  g   K   VP                   P                  S9  g   K=  Vx  KC  	  R # 5irx   )r   r   )ry   r   structured_mapview_maps   & r^   r|   #gen_source_files.<locals>.<genexpr>-
  s?      !A66;;n, 	
12H1L 	
!s   AA
AzRegisterFunctionalization.cpp)r  r  r  r  zFunctionalInverses.hc                 :   < R \        \        V 3R lS4      4      /# )view_inverse_declarationsc                   < \        SV 4      # rx   )r    r  rp  s   &r^   r   4gen_source_files.<locals>.<lambda>.<locals>.<lambda>G
  s    L !r`   )r   rI   rp  r  s   r^   r   r  D
  s$    '  	*	
r`   zViewMetaClasses.hc                 :   < R \        \        V 3R lS4      4      /# )view_meta_declarationsc                   < \        SV 4      # rx   )r!   r  s   &r^   r   r  U
      J8UVWr`   r   rE   r  s   r^   r   r  R
  s     $dW'
r`   zViewMetaClasses.cppc            	     d   < R \        \        V3R lS4      4      R\        \        S S4      4      /# )view_meta_implementationsc                   < \        SV 4      # rx   )r"   r  s   &r^   r   r  a
  r	  r`   
op_headersr
  )r  rp  r  s   r^   r   r  ^
  s3    'W* $yEF
r`   zCompositeViewCopyKernels.cppc                 4  < R S U u. uFL  p RP                  R V P                  f   V P                  .MV P                  V P                  . 4       4      NKN  	  up S U u. uF<  p RP                  R V P                  V P                  V P
                  3 4       4      NK>  	  up ,           R\        \        \        S\        P                  ,          4      S4      4      R\        \        \        S4      4      R\        \        \        S4      4      /# u up i u up i )r  r   c              3  \   "   T F"  pR VP                    RVP                    R2x  K$  	  R# 5i)r  _ops.h>
#include <ATen/ops/r  Nr  r  s   & r^   r|   5gen_source_files.<locals>.<lambda>.<locals>.<genexpr>}
  s@      	 S  *!++ 7* +,++j	B Sr  c              3     "   T F;  pVf   K	  RVP                   9  g   K  RVP                   RVP                   R2x  K=  	  R # 5i)Nr  r  r  r  )r   r  r  s   & r^   r|   r  
  sV       B	B *5AFF)B	B)!++ 7**+++jB Bs   AA%A#CompositeViewCopyKernel_Definitions(GeneratedCompositeFunctional_Definitions!GeneratedCompositeOut_Definitions)r  r  r  r   r8  r  r   rI   r#   r,   r  rA   rB   )r  rj   r  r  s    r^   r   r  {
  s'    % %A 		 	 %&KK$7affakk=RR	 	 %* 5	 5A 		   iiALLA	  5	. 24.''NN
  	4 73/9 0,/2Q.
	s   ADADN>   r  r  r   >   r  r  r  func_add_back_views_definitions!func_add_back_views_registrations)$r   r   r   r   r4   r=  r  r   r   r  r,   r  r/   r  gen_registration_headersgen_registration_helperswrite_sharded_with_templateCPUr  ufunc_inner_loopr1   r   r   r   rE  CUDAr   rD  rD   r  r  write_shardedr   r   rE   r  )/ri   r  r  r  rp  r  rj   r  r{  r  r  rp   r  r  r  r  r|  r  r  r  r  r  r  ns_grouped_native_functionsgrouped_native_functionr=  register_dispatch_key_base_envr  r  r  r  r  
all_groupsr   r  r  r  ro   r  r   r  r  r  r   r  r  r  s/   ddddddd$$$$$$dd$$d$$$             @@@@@@@@@@@@@r^   gen_source_filesr$    s   0&
 $ &+L*M&, &,T  (5&1$&7#'?# 5~FF (11,77AA 
 (	299:QR (@ !.446
 KMMM 	
 !#L11 #5& = =3T! +-' --m<*
&"	 	" 	&&|nD)%$(;(KOO;q301 	' 		
 -A55)))1F|1T1T<<$$))..D{.V#()WXX&&vT*"
 ..%dV40( !1!11F#IL&& c*"  %}\N*%MNNY -\ G &J #)'$?---	
 
( LL,.@AO *;;=
 	1)?	! LL	


 
 ,-J#.

 
'  4 LL$'MM%t,MM	
%N
 
$ 	()D- 	  8:UV:VA 	
QV:N
 !**G U4 U1Q U4H  !  '3
   LL		
 LL	

 LL	
: LL&.	
1g:4s   	 R3; R8c               $    V ^8  d   QhRRRRRR/# )rn   r  rG   ri   r   rs   r   ra   )rt   s   "r^   ru   ru   
  s$      +C	r`   c                4   a V P                  R V3R l4       R# )zDeclarations.yamlc                 V   < \        S U u. uF  p \        V 4      NK  	  up 4      # u up i rx   )r,  r|  )r   ri   s    r^   r   'gen_declarations_yaml.<locals>.<lambda>
  s%    BRSBRQ5a8BRSTSs   &N)rD  )r  ri   s   &fr^   gen_declarations_yamlr)  
  s     LLTr`   c                   V ^8  d   QhRR/# )rn   rs   r	   ra   )rt   s   "r^   ru   ru   
  s     + +4 +r`   c                 P    \        \        4      P                  P                  4       # )zs
If you're depending on torchgen out-of-tree, you can use the root to figure
out the path to native_functions.yaml
)r	   __file__parentresolvera   r`   r^   get_torchgen_rootr/  
  s    
 >  ((**r`   c                   V ^8  d   QhRR/# )rn   rs   r   ra   )rt   s   "r^   ru   ru   
  s     N1 N1d N1r`   c            	        \         P                  ! R R7      p V P                  RRRRR7       V P                  RRR	R
7       V P                  RRRR7       V P                  RRRR7       V P                  RRRRRR7       V P                  RRRRR7       V P                  RRRRR7       V P                  RRRR7       V P                  R RR!R7       V P                  R"RR#R7       V P                  R$RR%R7       V P                  R&R'R(R)R*7       V P                  R+R,R-R
7       V P                  R.R/R(R0R*7       V P                  R1R2R(R3R*7       V P                  R4R5RR6R7       V P                  R7R8RR9R7       V P                  R:\        R(. RoO. RoOR>R?7       V P                  R@RRAR7       V P                  RBRRCR7       V P	                  4       p\        VP                  VP                  4      p\        P                  P                  VP                  RD4      p\        P                  P                  VP                  RE4      p^ RFIHp \        P                  \        P                   \        P"                  \        P$                  \        P&                  \        P(                  \        P*                  \        P,                  0p\        P                  \        P                   R0p\/        4       p\        P0                  \        P2                  \        P4                  0p	VP6                  '       g   VP8                  '       d2   VP;                  V	4       VP=                  \        P0                  4       M.VP;                  V	4       V U
u. uF  qV	9  g   K  V
NK  	  up
VRG&   VP>                  '       g   VP8                  '       d@   VP=                  \        P@                  4       VP=                  \        P@                  4       MSVP=                  \        P@                  4       \        P@                  V9   d    WUPC                  \        P@                  4       VPD                  '       gT   VP=                  \        P,                  4       \        P,                  V9   d    WUPC                  \        P,                  4       VPF                  '       d?   V U
u. uF2  p
\I        V
4      '       g   \        V
4      VPF                  9   g   K0  V
NK4  	  pp
\K        W4V4      p\L        V,          pVPN                  VPP                  r\S        V4      pV Uu. uF  p\U        V\V        4      '       g   K  VNK  	  pp\Y        V4      pV Uu. uF  p\U        V\Z        4      '       g   K  VNK  	  ppVP\                   RH2p\_        V4      Pa                  RIRIRJ7       VP\                   RK2p\_        V4      Pa                  RIRIRJ7       VPb                   p\_        V4      Pa                  RIRIRJ7       VPd                  e   VPd                  pM VP\                  e   VP\                   RH2pMRLp\_        V4      Pa                  RIRIRJ7       \g        VVRM7      p\g        VRN7      p\g        VRN7      p\g        VRN7      p\g        VVRM7      p\g        VVRM7      p\g        VVRM7      pROV/pVP>                  '       d   \g        VRN7      VRP&   . p VPh                  '       dz   VPh                   U!u. uF   p!V\        Pj                  ! V!4      ,          NK"  	  p p!VPh                   F3  p!\        Pj                  ! V!4      p"V"V9  g   K"  VP=                  V"4       K5  	  R<VPl                  9   d   \o        Rp/ RQVbRRVbRSVbRTVbRUVbRVV bRWVbRXVbRYVbRZVbR[VbR\VbR]VbR^VbR_VPp                  bR`VPr                  bRaVPt                  bRbVPv                  bRcVP8                  bRdVbReVPx                  b  R;VPl                  9   dN   \{        Rp/ RQVbRfVbRRVbRSVbRVV bRUVbRWVbRgVbRYVbR[VbR\VbRhVbR]VbR^VbR_VPp                  bRaVPt                  b  R=VPl                  9   d   \}        VVRi7       VP~                  '       d   \_        VP~                  4      P                  4       p#V#P                  p$V#P                  p%VRj3VRk3VRl3VRm3.VP                  4        U&U'u. uF  w  p&p'V'V& Rn23NK  	  up'p&,            FD  w  p(p)V)V%,           p*V#P                  V)V$,           ,          p+V(P                  V*\        V+4      4       KF  	  R# R# u up
i u up
i u upi u upi u up!i u up'p&i )qzGenerate ATen source files)descriptionz-sz--source-pathz!path to source directory for ATenzaten/src/ATen)helpr,  z-oz--output-dependenciesz:output a list of dependencies into the given file and exit)r3  z	--dry-run
store_truez5run without writing any files (still updates outputs))actionr3  z--per-operator-headersz2generate separate headers per operator in ATen/opsz-dz--install-dirz--install_dirzoutput directoryzbuild/aten/src/ATenz--aoti-install-dirz--aoti_install_dirz%output directory for AOTInductor shimz(torch/csrc/inductor/aoti_torch/generatedz--headeronly-install-dirz--headeronly_install_dirzoutput directory for header-only generated files (e.g. enum_tag.h). Defaults to `<install-dir>/core` when --install-dir is set, otherwise `build/torch/headeronly/core`.Nz--rocmz=reinterpret CUDA as ROCm/HIP and adjust filepaths accordinglyz--mpsz'Generate MPS registration code when setz--xpuz'Generate XPU registration code when setz--mtiaz(Generate MTIA registration code when setz--op-registration-whitelistz--op_registration_whitelist*zfilter op registrations by the whitelist (if set); each item is `namespace`::`operator name` without overload name; e.g.: aten::empty aten::conv2d ...)nargsr3  z--op-selection-yaml-pathz--op_selection_yaml_pathaD  Provide a path to the operator selection (for custom build) YAML that contains the information about the set of selected operators and their categories (training, ...). Each operator is either a full operator name with overload or just a bare operator name. The operator names also contain the namespace prefix (e.g. aten::)z--backend-whitelistz--backend_whitelistzRfilter dispatch backend by the whitelist (if set), e.g.: CPU CUDA QuantizedCPU ...z--static-dispatch-backendz--static_dispatch_backendz?generate static dispatch code for the specific backend (if set)z!--skip-dispatcher-op-registrationz!--skip_dispatcher_op_registrationz0Avoid registering operators into the dispatcher.z--force-schema-registrationz--force_schema_registrationz}force it to generate schema-only registrations for all ops, includingthose that are not listed on --op-registration-whitelistz
--generater  sourcesdeclarations_yamlzGenerate only a subset of files)r   r7  choicesr,  r3  z--update-aoti-c-shimzUpdate AOTInductor C shim after adding an entry to inductor_fallback_ops in torchgen/aoti/fallback_ops.py. WARNING: Do not use this unless you are sure what you are doing!!!z--extend-aoti-c-shima  This Flag indicates the generation of c shims for out-of-tree ATen ops,which is an extension to the In-tree ATen op c shims. This flag needs to be combined with---source-path=<out-of-tree native_functions.yaml>--aoti-install-dir=<in-tree aoti_install_dir>/extend   default is torch/csrc/inductor/aoti_torch/generated/extendWARNING: Do not use this unless you are sure what you are doing!!!znative/native_functions.yamlznative/tags.yaml)r  :NNNz/coreT)parentsexist_okz/opszbuild/torch/headeronly/core)optionsinstall_dir)r=  cudaxpuri   r  r  r  rp  r  rj   r  r{  r  r  rp   r  r  r  r  r|  r  r  r  r  r   rz  rI  )ri   r  r~   cpu_vec_core_ops_r  )r  r8  r9  ra   )FargparseArgumentParseradd_argumentr   
parse_argsr  op_registration_whitelistr  osr   r  source_pathtorchgen.modelr  r,   r  r  r   r  r  r  r  MTIAr   MPS	SparseMPSSparseCsrMPSmpsr  r  r   r@  XPUr   mtiabackend_whitelistr0   r   rl   ri   rj   r  r   r5   r  r6   r>  r	   mkdiraoti_install_dirheaderonly_install_dirrH   static_dispatch_backendparsegenerater$  r  r  r|  r  r  r  r)  output_dependenciesr.  r   stemr   r-  write_outputs),parserr=  rp  native_yaml_pathr   r  r  r  r   MPS_KEYSr   parsed_yamlr   ri   rj   r  r  r  !native_functions_with_view_groupsr  core_install_dirops_install_dirrU  rV  r{  r  r  cuda_fmrI  r  rz  rp   r  keydp_keydepfile_pathdepfile_namedepfile_stemr{   	device_fmr   r  varnamer   s,                                               r^   mainrl  
  s^
   $$1MNF
0	   I  
 D  
  A  
 %   4:	   "")    L  
 6  
 6  
 7   %%-	   ""M   *	   ##N	   ++?	   %%C	   ;;.   M   M  	 !G())&&H
 ww||G$7$79WXWW\\'"5"57IJN,
 	--99--::	N 	 	M %K!6!68P8PQH{{{g000h'+//*8$'4J}!8IAA}Ja{{{g000;??++//*(??m+11+//BC<<<(()},11+2B2BCD    #
"&q))SVw7P7P-P A" 	 
 $$4kRK.~>J$$## &
  <<LM ,#+az!=Q/R+   # )M)%
 32Aa12 	
2    "--.e4	   = ,,-T2Ot<!223	   =%%1!(!?!?				($+$7$7#8!>!>	 &&td&C=MNGw/F"73J0GwOLF=MNG%%;M '"J{{{-g>
5.0&&& 66
6 K--c2336 	 
 22C &&s+F^+""6* 3
 G$$$ 	
-	
%=	
 )D	
 $		

 	
 !4	
 ,	
 	
 	
 "	
 	
 "	
 (	
 *	
 	
  '.&G&G!	
" ")!=!=#	
$ -4,S,S%	
&  '99'	
( ()	
*  '99+	
0 G$$$ 	
-	
!	
 &>	
 )D		

 !4	
 	
 ,	
 (	
 	
 	
 "	
 	
 (	
 *	
 	
  ")!=!=!	
& g.../?O"""G778@@B#((#(( RL$gV	

 AK@P@P@RS@R+<69iF81&@RST TJB |+G&&&<*?@DWc$i0T #_ K$
#^
F Ts<   e(e(-e-e-e2%e2<e7e7&e<?f__main__)N<stdin>F)rn  rx   )__conditional_annotations__
__future__r   rD  	functoolsr  r   rI  collectionsr   r   r   dataclassesr   r   pathlibr	   typingr
   r   r   r   typing_extensionsr   r   torchgen.api.dispatcherapir  torchgen.api.metar  torchgen.api.nativer  torchgen.api.structuredr   torchgen.destr  torchgen.apir   torchgen.api.translater   torchgen.api.typesr   r   r   r   r   r   r   torchgen.contextr   r   r   r   torchgen.gen_aoti_c_shimr   r   #torchgen.gen_functionalization_typer   r   r    r!   r"   r#   torchgen.gen_vmap_plumbingr%   rK  r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   #torchgen.native_function_generationr@   rA   rB   rC   !torchgen.selective_build.selectorrD   torchgen.utilsrE   rF   rG   rH   rI   rJ   rK   torchgen.yaml_utilsrL   rM   collections.abcrN   rO   rP   rR   rh   rk   r  rl   r   r   r   cacher   r   r   r   r  r  r  r   r?  rL  rY  rl  ro  r  r  r  r  r  r   r  r	  r,  r2  r9  r?  rK  rX  rW  r|  r  r  r  r  r  rt  r  r  r  r  r  r  r  rG  rx  r  r$  r)  r/  rl  rb   )ro  s   @r^   <module>r     si   " "     	 < < (  7 7 *  , ,     $ $ , ,   ,     =      8  ?   7 2 CLB  '9;L&MN
 :< !6 ;57 2 7&1#h( / /1
 !&1 "&1 1@=@
4	
(  ,FR$K<FX $` ` `0 $W& W& W&x $* * *^ $) ) )^ $  < M M
yx3 $@& @& @&TS&0
?'F
@!H U Ur " "@>0Of4 	00>4 	004(_H,`!=HvrDH5Vpf+N1b
 zF r`   