+
    &j,[                       ^ RI Ht ^ RIt^ RIt^ RIt^ RIHtHtHt ^ RI	H
t
 ^ RIHt ^ RIt^ RIHu Ht ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHtHtHtH t H!t!H"t" ^ RI#H$t$ ^ RI%H&t&H't'H(t(H)t)H*t* ^ RI+H,t, ]'       d   ^ RI-H.t. ]! R. RO4      t/R R lt0RR R llt1R R lt2RR R llt3R R R llt4RR R llt5]6R8X  d
   ]2! 4        R# R# )!    )annotationsN)Counterdefaultdict
namedtuple)Path)TYPE_CHECKING)DispatcherSignature)CodeTemplate)native_function_manager)get_grouped_native_functionsparse_native_yaml)BackendIndexBackendMetadataDispatchKeyNativeFunctionNativeFunctionsGroupOperatorName)SelectiveBuilder)	concatMapcontextFileManagerNamespaceHelperTarget)
YamlLoader)SequenceParsedExternalYamlc               (    V ^8  d   QhRRRRRRRR/# )	   backend_yaml_pathstrgrouped_native_functions/Sequence[NativeFunction | NativeFunctionsGroup]backend_indicesdict[DispatchKey, BackendIndex]returnr    )formats   "r/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torchgen/gen_backend_stubs.py__annotate__r)   +   s6     ] ]]M] 5] 	]    c           	       aaa \        R  V4       Uu/ uF  pVP                  P                  VbK  	  upo\        V 4      ;_uu_ 4       p\        P
                  ! V\        R7      pRRR4       \        X\        4      '       g   \        R\        V4       24      h. R'OpVP                  RR4      oSf   \        R4      hVP                  RR4      pVP                  RR4      oSf   \        R4      hVP                  RR4      p\        V\        4      '       g   \        RV 24      hVP                  RR4      p\        V\        4      '       g   \        RV 24      hVP                  R. 4      p	V	f   . p	\        V	\        4      '       g   \        RV	 R\        V	4       R24      hVP                  R. 4      p
V
f   . p
\        V
\        4      '       g   \        RV
 R\        V
4       R24      h\        V
4      pVP                  R. 4      p\        V\        4      '       g   \        RV 24      hVP                  R	. 4      pV	P                  V4       VP                  R
/ 4       VP                  R/ 4       \!        VP#                  4       4      ^ 8w  d@   \        V  RRP%                  VP#                  4       4       RRP%                  V4       24      hR VV3R llpRp\!        V	4      ^ 8  d\   \'        V3R l4      ;_uu_ 4        \(        P*                  ! S4      pRRR4       V! V	VVVVR7      pW9   d   \        R V 24      hVW/&   Rp\!        V4      ^ 8  da   \'        V3R! l4      ;_uu_ 4        \(        P*                  ! R"S 24      pRRR4       V! VVVVVR7      pVV9   d   \        R#V 24      hVVV&   V EF  p\        V\,        4      '       dk   Vf   . M-W/,          P/                  V4      3 Uu. uF  pVf   K	  VNK  	  uppVf   . M.VV,          P/                  V4      3 Uu. uF  pVf   K	  VNK  	  uppMVf   . MJVP1                  4        Uu. uF  pW/,          P/                  V4      NK  	  up Uu. uF  pVf   K	  VNK  	  uppVf   . MKVP1                  4        Uu. uF  pVV,          P/                  V4      NK  	  up Uu. uF  pVf   K	  VNK  	  uppV Uu. uF
  q3f   K  VNK  	  ppV Uu. uF
  q3f   K  VNK  	  pp\!        V4      ^ 8X  d   EKf  \!        V4      ^ 8X  d   EKy  \        R$V^ ,          P2                   R%V^ ,          P2                   R&24      h	  \5        VVVSV4      # u upi   + '       g   i     EL'; i  + '       g   i     EL; i  + '       g   i     EL%; iu upi u upi u upi u upi u upi u upi u upi u upi )(c                f    \        V \        4      '       d   V .# \        V P                  4       4      # N)
isinstancer   list	functionsfs   &r(   <lambda>$parse_backend_yaml.<locals>.<lambda>3   s%    Z>::qcSQ[[]@SSr*   )LoaderNz'Expected yaml_values to be a dict, got backend
class_namecpp_namespace	supportedautogradfull_codegen
non_nativeir_gensymintz&You must provide a value for "backend"z,You must provide a value for "cpp_namespace"use_out_as_primaryFzHYou must provide either True or False for use_out_as_primary. Provided: device_guardzBYou must provide either True or False for device_guard. Provided: z,expected "supported" to be a list, but got: z
 (of type )z)expected "symint" to be a list, but got: z+expected "autograd" to be a list, but got: z contains unexpected keys: z, z). Only the following keys are supported: c               0    V ^8  d   QhRRRRRRRRR	RR
R/# )r   backend_opsz	list[str]
symint_opszset[str]dispatch_keyr   r?   booluse_device_guardr%   r   r&   )r'   s   "r(   r)   (parse_backend_yaml.<locals>.__annotate__   sD     
 


 "

 !
 
 

r*   c                  < / pV  Fv  p\         P                  ! V4      pVS9  d   \        R V 24      h\        P                  ! SV,          P
                  4      pWa9   d
   VR,          p\        VRS
R7      p	WV&   Kx  	  \        VVRVVR7      # )z Found an invalid operator name: _symintF)kernel
structuredr8   T)rE   r?   externalr@   index)r   parseAssertionError
dispatchernamefuncr   r   )rC   rD   rE   r?   rG   metadataopop_namekernel_namemr8   native_functions_maps   &&&$$     r(   create_backend_index0parse_backend_yaml.<locals>.create_backend_index   s     9;B"((,G22$'Gy%QRR$//*>w*G*L*LMKy("uMA !"W  %1)
 	
r*   c                    < R S  R2# )zFThe provided value for "backend" must be a valid DispatchKey, but got .r&   r6   s   r(   r3   r4      s    \]d\eefgr*   )r?   rG   zDuplicate backend key: c                    < R S  R2# )zThe "autograd" key was specified, which indicates that you would like to override the behavior of autograd for some operators on your backend. However "Autogradz" is not a valid DispatchKey.r&   r^   s   r(   r3   r4      s     OOViWtvr*   AutogradzDuplicate autograd key: zCurrently, all variants of an op must either be registered to a backend key, or to a backend's autograd key. They cannot be mix and matched. If this is something you need, feel free to create an issue! z" is listed under "supported", but z is listed under "autograd".)
r6   r7   r8   extra_headersr9   r:   r;   r<   r=   r>   )r   rS   rR   openyamlloadr   r.   dictrP   typepoprF   r/   setextendlenkeysjoinr   r   rO   r   
get_kernelr0   rK   r   )r   r!   r#   r2   yaml_values
valid_keysr7   r?   rG   r9   r>   
symint_setsupported_autogradr;   rZ   backend_keybackend_idxautograd_keyautograd_idxgrX   forward_kernelsbackward_kernelsr6   r8   rY   s   &&&                    @@@r(   parse_backend_yamlry   +   s_    S$
@
A 	
Q
@ 
	 	 Aii*5 
!k4((5d;6G5HI
 	
J ooi.GEFFt4JOOOT:MKLL %)=uE($//VWiVjk
 	
 #~u=&--PQaPbc
 	
 R0I	i&&:9+ZPTU^P_O``ab
 	
 __Xr*F~fd##7xz$v,WXY
 	
 VJ$R8($//9:L9MN
 	

 ??>26L\" OOL"% OOHb!
;!# !!<TYY{GWGWGY=Z<[ \66:ii
6K5LN
 	


 
< '+K
9~g
 
 &++G4K

 +1-
 ) #:;-!HII'2$'+L
"v
 
 ',,xy-ABL	
 ,1-
 ?* #;L>!JKK(4%%a(( &  .:EEaHII AI   '  .l;FFqIJJ AJ  &  "#!.A (4??B!.  A   '  "#!.A (5@@C!.  A  '6Go11oG'7I'7!AA'7IO$)S1A-Ba-G P #1%,,- .'*1122N	P c &r \:}o m@ 
!	 	 d
 
 
$
 
 
, HIs}    U?	V	V6V,;W W 0W;W W
WW.!WWW,W6WW#W#V	V)	,V=	c               8    V ^8  d   QhRRRRRRRRR	R
RR
RRRR/# )r   native_functionszSequence[NativeFunction]r#   r$   rr   r   rt   DispatchKey | Noner7   r    kernel_defn_file_pathr;   zlist[OperatorName] | Noner%   Noner&   )r'   s   "r(   r)   r)     sb     R6 R6.R64R6 R6 %	R6
 R6 R6 ,R6 
R6r*   c                    \        V4      ;_uu_ 4       pVP                  4       pR R R 4       Tf   . pY,          P                  .Tf   . MY,          P                  .,           p
\        \        \        R T
4      4      4      pT  Uu. uF?  pTP                  P                  T9   g   K   TP                  P                  T9  g   K=  TNKA  	  pp\        \        4      pT F5  pTYP                  P                  ,          ,          P                  T4       K7  	  RT R2p\        \        P                  ! TX4       UUu. uF!  w  ppTP                  R4      '       d   K  TNK#  	  upp4      pRpTP!                  4        Fi  w  pp\#        T4      pTT,          pTT8w  g   K#  R R lpR	P%                  T Uu. uF  pT! T4      NK  	  up4      pTR	T R
T RT RT RT R2,          pKk  	  TR8w  d   \        T4      hR #   + '       g   i     EL; i  \         d   p	\        RT 24      T	hR p	?	ii ; iu upi u uppi u upi )Nz2Unable to read from the specified impl_path file: c                l    V P                  4        UUu. uF  w  rWP                  3NK  	  upp# u uppi r-   )itemsrK   )rN   rV   rT   s   &  r(   r3   *error_on_missing_kernels.<locals>.<lambda>'  s.    HMHU3D7Woo. s   0z(.*)z::\s*([\w\d]*)\(: c                    V ^8  d   QhRRRR/# )r   r2   r   r%   r    r&   )r'   s   "r(   r)   .error_on_missing_kernels.<locals>.__annotate__Q  s     J J~ J# Jr*   c                    \        V 4      ;_uu_ 4        \        P                  ! V P                  4      P	                  4       uuR R R 4       #   + '       g   i     R # ; ir-   )r   r	   from_schemarS   declr1   s   &r(   create_decl-error_on_missing_kernels.<locals>.create_declQ  s7    ,Q//.::166BGGI 0///s   .AA	
z$ is missing a kernel definition for z. We found z( kernel(s) with that name,
but expected zH kernel(s). The expected function schemas for the missing operator are:
z

)rb   readOSErrorrP   rN   re   r/   r   rS   rR   r   appendr   refindallendswithr   rj   rl   )r{   r#   rr   rt   r7   r}   r;   r2   backend_defnseindicesexpected_backend_op_namesexpected_backend_native_funcs#expected_backend_kernel_name_countsnative_fkernel_defn_regexxy!actual_backend_kernel_name_countsmissing_kernels_err_msgexpected_namefuncsexpected_overload_countactual_overload_countr   expected_schemas_strs   &&&&&&&                   r(   error_on_missing_kernelsr     sw   '((AFFHM ) +112")F)L)L(MG
 :> 		
	: ";!A66;;33 	
89<8W 	
! " ;
 LWL' 2+%mm&8&89	

&
 2  
|+;<(/ **%6F	
FA::c? AF	

)% ! C I I Ku"%e* A- P"&;;J $(99e-Lek!ne-L#M # ,0{K`Ja b%& '  ( # !L  "$455 %O )(( @AV@WX
	.;,	
" .MsW   H H H H6*H6H6>H;
H;
7I
 H	H H H3H..H3c                   V ^8  d   QhRR/# )r   r%   r~   r&   )r'   s   "r(   r)   r)   `  s     U Ud Ur*   c                 |   \         P                  ! R R7      p V P                  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R7       V P                  4       p\        VP                  VP                  VP                  VP                  4       R# )zGenerate backend stub files)descriptionz-sz--source-yamlz--source_yamlzApath to source yaml file containing operator external definitions)helpz-oz--output-dirz--output_dirzoutput directoryz	--dry-runz	--dry_runF)rf   defaultr   z--impl-pathz--impl_pathNz9path to the source C++ file containing kernel definitions)argparseArgumentParseradd_argumentrF   r    
parse_argsrunsource_yaml
output_dirdry_run	impl_path)parseroptionss     r(   mainr   `  s    $$1NOF
P	   nnCUV
[tUAS   H   !GW//'BSBSTr*   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   fmr   r7   r    r8   r#   r$   r!   r"   backend_dispatch_keyr   autograd_dispatch_keyr|   backend_namer%   r~   r&   )r'   s   "r(   r)   r)   x  sc     7 777 7 5	7
 N7 &7 .7 7 
7r*   c                  aaaaaaa	a
a Sf   \        R4      hRo
\        \        \        VV3R lV4      4      4      o	\        \        \        VV3R lV4      4      4      o\	        V4      oV P                  S R2RVV	VVVV
V3R l4       R # )Nclass_name must not be NonezAAutogenerated file by gen_backend_stubs.py. Do not edit directly!c                @   < \         P                  ! V SS,          4      # r-   dest#compute_native_function_declaration)r2   r   r#   s   &r(   r3   4gen_dispatchkey_nativefunc_headers.<locals>.<lambda>  s    $BB';<r*   c                L   < Sf   . # \         P                  ! V SS,          4      # r-   r   )r2   r   r#   s   &r(   r3   r     s1    (0  =='<=r*   NativeFunctions.hzDispatchKeyNativeFunctions.hc                 Z   < R SRSP                   RSRSP                  RSS ,           RSRS/# )generated_commentnamespace_prologuer7   namespace_epiloguedispatch_declarationsBackendNamer   )prologueepilogue)autograd_declarationsbackend_declarationsr   r   r7   r   	ns_helpers   r(   r3   r     s@    !2 )"4"4* )"4"4#%9<Q%Q</
r*   )rP   sortedrh   r   r   write_with_template)r   r7   r8   r#   r!   r   r   r   r   r   r   r   s   &f&f&fff@@@@r(   "gen_dispatchkey_nativefunc_headersr   x  s     :;;K  " )		
	 #
 )		
  .I
  12&	
 	
r*   c               L    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    r7   r#   r$   r!   r"   r   r   rE   selectorr   build_in_treerF   per_operator_headersr   eager_registrationr%   r~   r&   )r'   s   "r(   r)   r)     s     p ppp p 5	p
 Np &p p p p p p p 
pr*   c                L  a aaaaa	aaaaaa V R V R2.pV'       d   RP                  R V 4       4      oMRP                  R V 4       4      oSf   \        R4      hVS,          o\        \        \        P
                  ! S\        P                  SRRS RR	7      S4      4      pRo\        R
R7      oRoRoV'       d    \        R4      pVP                  SVR7      oM\        R4      pVP                  V
SVR7      oS P                  RS R2RVVVVVV VVVV	VV3R l4       R# )/r   r   c              3  .   "   T F  pR V R2x  K  	  R# 5i)z
#include <>Nr&   .0hs   & r(   	<genexpr>/gen_dispatcher_registrations.<locals>.<genexpr>       0TGq:aS1BG   c              3  .   "   T F  pR V R2x  K  	  R# 5i)z
#include ""Nr&   r   s   & r(   r   r     r   r   Nr   FTrocmr>   class_method_nameskip_dispatcher_op_registrationat)namespace_strr   zOTORCH_LIBRARY_IMPL(aten, $dispatch_key, m) {
    $dispatch_registrations_body
})rE   dispatch_registrations_bodyzTORCH_API void Register${backend_name}${dispatch_key}NativeFunctions();
TORCH_API void Register${backend_name}${dispatch_key}NativeFunctions() {
    static auto m = MAKE_TORCH_LIBRARY_IMPL(aten, $dispatch_key);
    $dispatch_registrations_body
})r   rE   r   Registerz.cppzRegisterDispatchKey.cppc                   < R RRSRS	'       g   RMRRSRSP                  4       R\        P                  ! S S	RR	7      R
\        P                  ! S 4      RSP	                  RV VVVVVV
V3R l4      P                  S4      /# )extra_cuda_headersr   external_backend_headersops_headersz#include <ATen/Functions.h>r   dispatch_namespacedispatch_headersF)r   r   dispatch_helpersdispatch_definitionszRegisterDispatchDefinitions.inic                    < R SP                   RSP                  RSRSRSP                  4       RRR\        \	        \
        P                  ! S \        P                  SRR	S RR
7      S4      4      /# )ns_prologuens_epilogue"static_init_dispatch_registrationsdeferred_dispatch_registrationsr   dispatch_namespaced_definitionsr   dispatch_anonymous_definitionsFTr   )	r   r   lowerr/   r   r   RegisterDispatchKeyr   ANONYMOUS_DEFINITION)backend_indexr7   r   rE   r!   r   r   r   s   r(   r3   @gen_dispatcher_registrations.<locals>.<lambda>.<locals>.<lambda>
  s    !9#5#5!9#5#58:\57V(,*<*<*>5r4d! 44 - & ; ; (%*'+5?L@E 57r*   )r   r   gen_registration_headersgen_registration_helperssubstitute_with_templatesplit)r   r7   r   rE   external_backend_headers_strr   r!   newliner   r   r   r   s   r(   r3   .gen_dispatcher_registrations.<locals>.<lambda>  s     "&(D' 9< ,"4"4"6 = =4Hu!  = =m L"B$?$?1 %0 eGnI%
r*   )rl   rP   r/   r   r   r   r   REGISTRATIONr   r
   
substituter   )r   r   r7   r#   r!   r   rE   r   r   r   r   r   headersr   static_templatedeferred_templater   r   r  r  r   r   s   f&f&f&ff&f&&    @@@@@@r(   gen_dispatcher_registrationsr    sY     ,a,-->?G '+yy0TG0T'T$'+yy0TG0T'T$:;;#L1M"&$$##%/L05 %	
# Gd3I&(#)+&&
 .=-G-G%(C .H .
*
 )
 +<*F*F%%(C +G +
' 
<.%!%	
 %	
)r*   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r   r   r    r   r   rF   r   z
str | Noner%   r~   r&   )r'   s   "r(   r)   r)   %  s;     R
 R
R
"%R
04R
AKR
	R
r*   c                  aa \        \        4      P                  4       P                  P                  p\        P
                  P                  VR 4      p\        P
                  P                  V4      '       g!   \        P
                  P                  VR4      p\        P
                  P                  VR4      oR VV3R llpV! V4      p\        P
                  P                  VR4      p\        P
                  P                  VR4      p	\        W4      p
V
P                  V
P                  r\        V4      p\        WV4      pVP                  pVP                  pVP                  pVP                   pVP                  p\"        P$                  ! 4       pVf   R# Vf   W,          P'                  4       pVf   \)        R4      hVe   \+        VVVVVV4       \-        VVVVVVV4       Vf   V.MVV. F  p\/        VVVVVVVV4       K  	  R# )	zaten/srcztorchgen/packagedzATen/templatesc                    V ^8  d   QhRRRR/# )r   install_dirr    r%   r   r&   )r'   s   "r(   r)   run.<locals>.__annotate__0  s     
 
s 
{ 
r*   c                    < \        V SSR 7      # ))r  template_dirr   )r   )r  r   r  s   &r(   make_file_managerrun.<locals>.make_file_manager0  s    #,
 	
r*   z!ATen/native/native_functions.yamlzATen/native/tags.yamlNr   )r   __file__absoluteparentospathrl   existsr   r{   r#   r   ry   rr   rt   r8   r7   r   get_nop_selectornative_function_class_namerP   r   r   r  )r   r   r   r   root
common_dirr  r   native_yaml_pathtags_yaml_pathparsed_yamlr{   r#   r!   parsed_backend_yamlrr   rt   r8   r7   r   rE   r  s   &&f&                 @r(   r   r   %  s    >""$++22DdJ/J77>>*%%WW\\$(;<
77<<
,<=L
 

 
:	&Bww||J0STWW\\*.EFN#$4EK$$## &  <<LM, &11K&33L'55M$//J)99O002H
 %1LLN
:;; 	
 '
  &-K3NN 	 	%$		
 	Or*   __main__)rr   rt   r7   r8   r#   r-   )r   )FFr   T)7
__future__r   r   r  r   collectionsr   r   r   pathlibr   typingr   rc   torchgen.api.dispatcherapirQ   torchgen.destr   torchgen.api.typesr	   torchgen.code_templater
   torchgen.contextr   torchgen.genr   r   torchgen.modelr   r   r   r   r   r   !torchgen.selective_build.selectorr   torchgen.utilsr   r   r   r   r   torchgen.yaml_utilsr   collections.abcr   r   ry   r   r   r   r  r   __name__r&   r*   r(   <module>r6     s    "  	 	 8 8     , ,  2 / 4 H  ? S S * (
  U ]@R6jU07tpfR
j zF r*   