+
    &j                       a  R? t_0 t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
 ^ RIHt ^ RIHtHtHtHtHtHt ^ RIHtHt ^ RIt^ RIHu Ht ^ RIHt ^ RIHtH t  ^ RI!H"t"H#t# ^ R	I$H%t%  ^ R
IH&t& ]'       d   ^ RI*H+t+ ]! R]R7      t,]! RRR7      t-].! ]R4      ;'       d
    ].! ]R4      t/]P`                  R 4       t1 ! R R4      t2R R lt3/ t4] ^ k ] Pj                  ] Pl                  ] Pn                  ] Pp                  ] Pr                  ] Pt                  ] Pv                  .t< ! R R]2]Pz                  4      t>R t?R t@R tAR tB ! R R4      tC]C! 4       sDR@R ltER  tFR! tGR" tHR# tIR$ tJR% tK]L! 4       sM] ^k R& tNR' tOR( tP ! R) R*]2]]-],3,          4      tQ ! R+ R,]Q]-],3,          4      tRR- R. ltSR/ R0 ltTR1 R2 ltU ! R3 R4]]-],3,          4      tVR5 R6 ltW ! R7 R8]P                  4      tYR9 tZR: t[ ! R; R<]P                  4      t\ ! R= R>]P                  4      t]]]! 4       t^] ^k R#   ]' d    ](! ])4      t& ELi ; i)A    N)CallableIterator)cached_property)AnyClassVarConcatenatefinalGenericTYPE_CHECKING)	ParamSpecTypeVar)_utils_internal)_dispatch_is_included_in_aliasDispatchKey)dispatch_functorchTransformType)TorchDispatchMode)NotImplementedType)BaseFunctionalizeAPI_Tdefault_P.getdlopenflagssetdlopenflagsc               #    "   \         '       g   Rx  R# \        P                  ! 4       p \        P                  ! V \        P
                  ,          4        Rx  \        P                  ! V 4       R#   \        P                  ! T 4       i ; i5i)zu
Context manager to set the RTLD_GLOBAL dynamic linker flag while we open a
shared library to load custom operators.
N)_SET_GLOBAL_FLAGSsysr   r   ctypesRTLD_GLOBAL)	old_flagss    b/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/_ops.pydl_open_guardr#   (   s^      ""$Iy6#5#556&9%9%s   ABA2 B2B

Bc                   f   a  ] tR t^9t o RtR tR tR tR tV 3R lR lt	V 3R lR	 lt
R
 tRtV tR# )OperatorBasez
Base class for OpOverload (which represents C++ ATen operators) and HigherOrderOperator
(which represents Python-only operators that are unrepresentable in TorchScript).
c                >    / V n         / V n        / V n        / V n        R # N)_dispatch_cache
py_kernelspython_key_tablefunctorch_tableselfs   &r"   __init__OperatorBase.__init__?   s0      UW BD  	  "    c                    \         hr'   NotImplementedErrorr-   argskwargss   &*,r"   __call__OperatorBase.__call__i       !!r0   c                    WP                   9   # r'   )r)   )r-   ks   &&r"   has_kernel_for_dispatch_key(OperatorBase.has_kernel_for_dispatch_keyl   s    OO##r0   c                    V P                    FD  p\        P                  P                  V4      '       d   K*  VP	                  V4      '       g   KC   R # 	  R# )TF)r)   torch_C_dispatch_is_alias_keyhas)r-   ksr;   s   && r"   has_kernel_for_any_dispatch_key,OperatorBase.has_kernel_for_any_dispatch_keyo   s9    A8822155"&&)) ! r0   c                   < V ^8  d   QhRS[ S[,          S[ S[P                  ,          ,          S[,          S[,          RS[S[S[S[3,          .S[S[S[3,          3,          /#    r;   return	typer   r?   Tensorr   r   r   r   r   )format__classdict__s   "r"   __annotate__OperatorBase.__annotate__u   s\     $ $!"T%,,%77-G+U$ 
8BF#$hr2v&66	7$r0   c                   a a R  VV 3R llpV# )c                t    V ^8  d   QhR\         \        \        3,          R\         \        \        3,          /# rH   fnrI   r   r   r   )rM   s   "r"   rO   *OperatorBase.py_impl.<locals>.__annotate__y   s,     	 	hr2v& 	8BF+; 	r0   c                   < \         P                  ! S4      '       d   \        S\        4      '       g!   \        S\        P
                  4      '       dK   SSP                  9   d   \        S R 24      hV SP                  S&   SP                  P                  4        V # \        S\        4      '       d1   SSP                  9   d   \        S R24      hV SP                  S&   V # \        S\        4      '       g   \        R\        S4       24      hS\        P                  8X  d   \        R4      hSSP                   9   d    \#        RS RSP%                  4        24      hV SP                   S&   SP                  P                  4        V # )z' already registered in python_key_tablez& already registered in functorch_tablezexpected DispatchKey, got z>Please register a mode for the DispatchKey.Python key instead.z%Trying to override a python impl for z on operator )inspectisclass
issubclassr   r?   rL   r*   AssertionErrorr(   clear
isinstancer   r+   r   rK   Pythonr)   RuntimeErrorname)rT   r;   r-   s   &r"   inner#OperatorBase.py_impl.<locals>.innery   sU   q!!1/00Jq%,,4O4O---(A3.U)VWW+-%%a($$**,	!]++,,,(A3.T)UVV*,$$Q'	a--$'A$q'%KLLK&&&$T  DOO#";A3mDIIK=Y  "$DOOA  &&(Ir0    )r-   r;   ra   s   ff r"   py_implOperatorBase.py_implu   s    	 	@ r0   c                z   < V ^8  d   QhRS[ S[RS[3,          S[3,          RS[ S[RS[3,          S[3,          /# )rH   rT   r   rI   )r   r   r   r   )rM   rN   s   "r"   rO   rP      sG     & &;'=r'ABBFG&	+4b892=	>&r0   c                ,  aaaaa ^ RI HoHoHoHo R VV3R llpV3R lVV3R llpR VV3R llpV P                  \        P                  4      ! V4       V P                  S4      ! V4       V P                  \        P                  4      ! V4       S# )r   )CppFunctionalizeAPIFunctionalTensorModeFunctorchFunctionalizeAPIPythonFunctionalizeAPIc                d    V ^8  d   QhR\         P                  R\         P                  R\        /# rH   r5   r6   rI   r   r5   r6   r   )rM   s   "r"   rO   8OperatorBase.py_functionalize_impl.<locals>.__annotate__   s)     	> 	>rww 	>")) 	> 	>r0   c                  &   < S! S! 4       .V O5/ VB # r'   rc   )r5   r6   rh   rT   s   *,r"   functionalize_dk_fn?OperatorBase.py_functionalize_impl.<locals>.functionalize_dk_fn   s    )+=d=f==r0   c          	         < V ^8  d   QhRSR,          R\         P                  R\         P                  R\        \        ,          /# )rH   modeNr5   r6   rI   )r   r5   r6   r   r   )rM   ri   s   "r"   rO   ro      sF     	E 	E&-	E68gg	EIK	E$$	Er0   c                 |   < ^ RI Hp ^ RIHp ^ RIHp V! W3WE3R7      '       d   \        # S! S! V 4      .VO5/ VB # )r   )has_user_subclass)
FakeTensor)FunctionalTensor)allowed_subclasses)torch._higher_order_ops.utilsrv   torch._subclassesrw   #torch._subclasses.functional_tensorrx   NotImplemented)rt   r5   r6   rv   rw   rx   rk   rT   s   &*,   r"   functionalize_dispatch_mode_fnJOperatorBase.py_functionalize_impl.<locals>.functionalize_dispatch_mode_fn   sJ     H4L $.#A  &%,T2DTDVDDr0   c                d    V ^8  d   QhR\         P                  R\         P                  R\        /# rm   rn   )rM   s   "r"   rO   ro      s1     	O 	O "	O3599	O	Or0   c                 (   < S! S! V 4      .VO5/ VB # r'   rc   )interpreterr5   r6   rj   rT   s   &*,r"   functionalize_functorch_fnFOperatorBase.py_functionalize_impl.<locals>.functionalize_functorch_fn   s      /<NtNvNNr0   )	r|   rh   ri   rj   rk   rd   r   Functionalizer   )	r-   rT   rq   r~   r   rh   ri   rj   rk   s	   &f   @@@@r"   py_functionalize_impl"OperatorBase.py_functionalize_impl   sy    	
 	
	> 	>	E 	E	O 	O
 	[../0CD)*+IJ]0012LM	r0   c                    \         hr'   r2   r,   s   &r"   r`   OperatorBase.name   r9   r0   )r(   r+   r)   r*   N)__name__
__module____qualname____firstlineno____doc__r.   r7   r<   rD   rd   r   r`   __static_attributes____classdictcell__rN   s   @r"   r%   r%   9   s?     
("T"$$ $b& &P" "r0   r%   c                0    V ^8  d   QhR\         R\        /# )rH   opr;   )r%   r   )rM   s   "r"   rO   rO      s     2U 2UL 2U[ 2Ur0   c                 l   V P                  V4      '       d   V# \        P                  pV\        P                  8X  g   \	        W4      '       d   V P                  V4      '       d   V# \        P
                  pV\        P                  8X  g   \	        W4      '       d   V P                  V4      '       d   V# V P                  \        P                  P                  V4      4      ;'       g     V P                  \        P
                  4      p\        P                  pV\        P                  8w  d3   \	        W4      '       d"   V P                  V4      '       d   V'       g   V# \        P                  pV\        P                  8X  g   \	        W4      '       dq   V P                  V4      '       dZ   V\        P                  8X  d;   V P                  \        P                  P                  4      '       d   \        R 4      hV'       g   V# \        P                  p\	        W4      '       d   V P                  V4      '       d   V# \        P                   p\	        W4      '       d   V P                  V4      '       d   V# \        P                  P#                  V4      '       d   V# \%        RV  RV 24      h)zambiguous autogradother kernelzcould not find kernel for  at dispatch key )r<   r   &CompositeExplicitAutogradNonFunctional	Undefinedis_included_in_aliasCompositeExplicitAutogradrD   r?   r@   *_dispatch_get_backend_keyset_from_autograd%CompositeImplicitAutogradNestedTensorCompositeImplicitAutogradAutogradOther _dispatch_autogradother_backendsr_   AutogradFuncTorchBatchedDecomposition_dispatch_has_backend_fallbackr3   )r   r;   candhas_backend_kernels   &&  r"   resolve_keyr      s   	%%a((==D	["""&:1&C&C

(
(
.
.00D	["""&:1&C&C

(
(
.
.;;;;A> O O		'	'(M(M	N  <<D	
k##	#(<Q(E(E**400"00D	["""&:1&C&C

(
(
.
.)))b.P.PHH55/
 /
 ?@@#KDA$$)G)G)M)M44DA$$)G)G)M)Mxx..q11 
 :2$>OPQsS
TTr0   c                      a a ] tR tRt oRRRR/V 3R lltV3R lV 3R lltV3R lR	 lt]R
 4       t]	V3R lR l4       t
R tR t]P                  R 4       tR tR tR tRR ltRtVtV ;t# )HigherOrderOperatori  	cacheableF supports_training_input_mutationc               @  < \         SV `  4        \        V 4      \        J d   \	        R 4      hWn        Wn        V \        V&   RV n        RV n	        W n
        W0n        \        P                  P                  4       V n        \          F  pV P#                  V4       K  	  R# )zODirect instantiation of HigherOrderOperator is not allowed. Please subclass it.higher_ordertorch.ops.higher_orderN)superr.   rK   r   r_   _namer   _higher_order_ops_nsr   
_cacheable!_supports_training_input_mutationr?   r@   _dispatch_keyset_fullnon_fallthrough_keys2_HIGHER_ORDER_OP_DEFAULT_FALLTHROUGH_DISPATCH_KEYSfallthrough)r-   r`   r   r   dispatch_key	__class__s   &&$$ r"   r.   HigherOrderOperator.__init__  s     	:,,a  
 "&$!2# 2R.$)HH$B$B$D!NL\* Or0   c                   < V ^8  d   QhRS[ S[,          S[ S[P                  ,          ,          S[,          S[,          RS[S[S[S[3,          .S[S[S[3,          3,          /# rG   rJ   )rM   rN   s   "r"   rO    HigherOrderOperator.__annotate__=  s\     " "!"T%,,%77-G+U" 
8BF#$hr2v&66	7"r0   c                   < \        V\        4      '       dB   V P                  P                  V4      '       g!   V P                  P	                  V4      V n        \
        SV `  V4      # r'   )r]   r   r   rB   addr   rd   r-   r;   r   s   &&r"   rd   HigherOrderOperator.py_impl=  sP     a%%d.G.G.K.KA.N.N(,(A(A(E(Ea(HD%wq!!r0   c                R   < V ^8  d   QhRS[ S[S[3,          RS[ S[S[3,          /# rS   rU   )rM   rN   s   "r"   rO   r   E  s1      RV 
"b&	r0   c                h   a a R  VV 3R llpS P                  \        P                  4      ! V4       S# )c                d    V ^8  d   QhR\         P                  R\         P                  R\        /# rm   rn   )rM   s   "r"   rO   :HigherOrderOperator.py_autograd_impl.<locals>.__annotate__I  s)     	' 	'bgg 	' 	'r 	'r0   c                    < \         P                  ! 4       '       d3   \        P                  ! \         P                  R  . V OVN54      '       d:   \         P
                  P                  4       ;_uu_ 4        S! V / VB uuRRR4       # ^ RIHp SP                  '       g   V! S4      '       d~   SP                  ! V / VB p\        ;QJ d&    R VP                   4       F  '       g   K   RM	  RM! R VP                   4       4      '       d   \        RSP                  4        R24      hS! V / VB #   + '       g   i     L; i)c                 $    V P                   '       * # r'   )requires_grad)ts   &r"   <lambda>RHigherOrderOperator.py_autograd_impl.<locals>.maybe_run_autograd.<locals>.<lambda>L  s    aoo-r0   N)_has_gen_schemac              3   8   "   T F  qP                   x  K  	  R # 5ir'   )is_write.0args   & r"   	<genexpr>SHigherOrderOperator.py_autograd_impl.<locals>.maybe_run_autograd.<locals>.<genexpr>V  s     @/?||/?   TFzThe z HigherOrderOperator does not currently support training with in-place input or buffer mutations If you require this feature, please submit an issue to PyTorch. Alternatively, consider creating your own custom autograd.Function. )r?   is_grad_enabledpytreetree_all_onlyrL   r@   _AutoDispatchBelowAutogradrz   r   r   
gen_schemaany	argumentsr_   r`   )r5   r6   r   schemarT   r-   s   *,  r"   maybe_run_autograd@HigherOrderOperator.py_autograd_impl.<locals>.maybe_run_autogradI  s    ((**f.B.B-$/ /
 XX88::00 ;: F999od>S>S$9&93@v/?/?@333@v/?/?@@@&tyy{m ,_ _  t&v&& ;:s   5D33E	)rd   r   r   )r-   rT   r   s   ff r"   py_autograd_impl$HigherOrderOperator.py_autograd_implE  s,    	' 	'. 	[))*+=>	r0   c                    V P                   # r'   )r   r,   s   &r"   	namespaceHigherOrderOperator.namespaced      xxr0   c                    < V ^8  d   QhRS[ /# rH   rI   bool)rM   rN   s   "r"   rO   r   i  s     
 
4 
r0   c                4   ^ RI Hp V P                  ;'       g    V P                   RV P                   2\
        P                  P                  P                  9   ;'       g8    \        W4      ;'       d%    \
        P                  P                  P                  # )r   )AutogradFunctionApply.)"torch._functorch.autograd_functionr   r   r   r   r?   	_inductorconfig!unsafe_marked_cacheable_functionsr]   
_functorch.autograd_cache_allow_custom_autograd_functions)r-   r   s   & r"   r   HigherOrderOperator.cacheableh  s    L OO  //"!DMM?3%%GGH  47 [ [$$++ZZ	
r0   c                F    V P                   P                  V4      V n         R # r'   )r   remove)r-   r   s   &&r"   r   HigherOrderOperator.fallthroughv  s    $($=$=$D$D\$R!r0   c               d
  aa ^ RI Hp WP                  9   d@   V P                  V,          p\        V\        4      '       d   \        RV 24      hV! V/ VB # V\        P                  8X  d   \        WV4      # V\        P                  8X  Ed   . oR oVV3R lp. VOVP                  4       O F:  pV! V4       \        V\        \        34      '       g   K)  V F  pV! V4       K  	  K<  	  \        S4      p	^ RI Hp
 V! 4       pVe   \        V4      V P                  9   dB   V P                  \        V4      ,          pV
! 4       ;_uu_ 4       pV! V.VO5/ VB pRRR4       MqVP                  '       d.   V
! 4       ;_uu_ 4       pVP!                  V . W#4      uuRRR4       # \#        RV P$                   RV R	V R
V RV P$                   RV R24      hX\&        Jd   V# V	 EF  p\        V4      pVP                   \(        P*                  P,                  J d   K9  V\(        P.                  P0                  P2                  J dR   \(        P.                  P0                  P4                  pV P                  V,          pV! VP6                  .VO5/ VB pVu # WP                  9   d   V P                  V,          pV! V/ VB pM\#        RV P$                   RV R24      hV\&        Jg   EK  Vu # 	  \9        RV P$                   RT RV	 Uu. uF  p\        V4      P:                  NK  	  up RV P$                   RV R24      h\(        P*                  P=                  V4      pV\        P>                  8X  d   ^ RI Hp
 \A        4       ^ 8  d   \(        P*                  PC                  \        P                  4      '       g   \E        4       pVf   \        R4      h\        V4      V P                  9  d   \        RV R24      hV P                  \        V4      ,          pV
! V4      ;_uu_ 4       pV! V.VO5/ VB uuRRR4       # \G        W4      pVV PH                  9  d    \#        RV P$                   RV RV R24      hV\        P>                  8w  d!   V PH                  V,          V P                  V&   V PH                  V,          p\        V\        4      '       d   \        RV 24      hV! V/ VB #   + '       g   i     EL.; i  + '       g   i     ELB; iu upi   + '       g   i     L; i)r   _get_current_dispatch_modez!unexpected DispatchKey in cache: c                 ^    \         P                  P                  V 4      P                  R 4      # )r^   )r?   r@   _dispatch_keysrB   )tensors   &r"   has_python_key4HigherOrderOperator.dispatch.<locals>.has_python_key  s"    xx..v6::8DDr0   c                    < \        V \        P                  4      '       d$   S! V 4      '       d   SP                  V 4       R # R # R # r'   )r]   r?   rL   append)r   r   overloaded_args_lists   &r"   check_overloaded6HigherOrderOperator.dispatch.<locals>.check_overloaded  s5    c5<<00^C5H5H(//4 6I0r0   )_pop_mode_temporarilyNz5There was no rule registered for HigherOrderOperator z
 and mode z.Hint: set zc's supports_higher_order_operators to True. This causes all higher order operators to pass through zk's __torch_dispatch__, so handle them accordingly by adding support for HigerOrderOperators (in this case, z) in zC.__torch_dispatch__ or returning NotImplemented when not supported.z%There was no rule registered for HOP z and subclass z. We recommend filing an issue.zHigherOrderOperator 'z' is not supported for the given input types. This typically happens when using custom tensor types or dispatch modes that don't have implementations for this operation.

Current mode: z
Input types: z$

To fix this, can add support for 'z' in z's __torch_dispatch__
zIIllegal invocation of dispatch on DispatchKey.PreDispatch without a mode.zCurrent active mode z not registeredz.could not find kernel for HigherOrderOperator r   z (resolved from )z&unexpected DispatchKey in py_kernels: )%torch.utils._python_dispatchr   r(   r]   r   r[   FuncTorchDynamicLayerFrontModer   r^   valueslisttupler   rK   r*   supports_higher_order_operators__torch_dispatch__r3   r   r}   r?   r@   _disabled_torch_dispatch_impl_subclassesfake_tensorrw   FakeTensorMode	fake_mode	TypeErrorr   _to_functionality_keyPreDispatch&_len_torch_dispatch_stack_pre_dispatch&_dispatch_tls_is_dispatch_key_excluded'_get_current_dispatch_mode_pre_dispatchr   r)   )r-   r   r5   r6   r   kernelr   r   aoverloaded_argsr   	curr_modehandlerrt   resultsubclass_typefunctionality_key	final_keyr   r   s   "&*,              @@r"   dispatchHigherOrderOperator.dispatch{  s   K///)),7F&+..$'H%QRR4*6**;EEE%d&99;--- $& E5 100 %cD%=11 (+ ! 1 $$89O K24I$	?d&;&;;"33DODG.00D ")!?!?!? 10
 !@@@244#,#?#?b$#W 54 2STXT^T^S__ijsit u))2 4WW`Va bVVZV`V`Ua b  ){ +LM  /!M ' $S	!44xx==>  !E$5$5$A$A$L$LL$)$5$5$A$A$P$PM"33MBG$S]]DTDVDF!M $9$99"33MBG %d5f5F-?

|>ZgYh i8 9  /!M= 'B '

| 4! "+ , ;J K?aa!1!1? KL M559ZZLi[Pgi  "HH::<H 7 77J
 781<hhEE""  DE	$(c  	?$*?*??(.ykI  //Y@*+<=="49$9&9 >=  3	 DOO+%@ M##,+-=l^1N  ;222151KD  .+ fk** #I&!RSSt&v&&[ 100 544l !L2 >=s*   S2T
T,T2T	T	T/	c                  \        W4      p\        P                  P                  V4      '       d%   \        P                  P                  ! W.VO5/ VB # \        WV P                  4      pV P                  ! VP                  4       .VO5/ VB # r'   )	_to_flat_tupler?   	overrideshas_torch_functionhandle_torch_function_compute_keysetr   r  highestPriorityTypeId)r-   r5   r6   	flat_argsdispatch_key_sets   "*,  r"   r7   HigherOrderOperator.__call__  s    "40	??--i88??88"&*0  +49R9RS}}-CCEWWPVWWr0   c                4    \        R V P                   R24      h)zHigherOrderOperator z does not implement a gen_schema. This is OK as long as the hop is functional. e.g. it should not mutate its inputs and there are no input, output aliasing via views or direct referencing.)r3   r   r4   s   &*,r"   r   HigherOrderOperator.gen_schema)  s$    !"4::, // 0
 	
r0   c                $    V P                  4        # r'   )r`   r,   s   &r"   __str__HigherOrderOperator.__str__1  s    ))+r0   c                    V P                   # r'   r   r,   s   &r"   r`   HigherOrderOperator.name4      zzr0   c                    V # r'   rc   r-   memos   &&r"   __deepcopy__ HigherOrderOperator.__deepcopy__8      r0   )r   r   r   r   r   r   r   r'   )r   r   r   r   r.   rd   r   propertyr   r	   r   r   r  abcabstractmethodr7   r   r,  r`   r5  r   r   __classcell__r   rN   s   @@r"   r   r     s     +!&+IN+D" " >   
 
S
U'n 	X X,
  r0   r   c                 .    \         P                  ! V / VB # r'   )r   arg_tree_leavesr5   r6   s   &&r"   r   r   <  s    !!42622r0   c                 .    \        W4      p\        W24      # r'   )_get_tensorskey_extractor)r5   r6   r   tensorss   &&& r"   r$  r$  @  s    4(G77r0   c                     \        W4      pV Uu. uF'  p\        V\        P                  4      '       g   K%  VNK)  	  pp\	        V4      # u upi r'   )r   r]   r?   rL   r  )r5   r6   flat_allr   tensor_argss   &&   r"   rA  rA  E  s@    d+H&Fh*Q*E11hKF Gs
   "A
A
c                     \         P                  P                  4       pV  F)  pV\         P                  P                  V4      ,          pK+  	  V\         P                  P	                  4       ,
          pW!,          pV# r'   )r?   r@   _dispatch_tls_local_include_setr   _dispatch_tls_local_exclude_set)rC  key_maskkey_setr   s   &&  r"   rB  rB  M  s[    hh668GEHH33F;; @@BBG GNr0   c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )_ModeStackStateForPreDispatchic  c                &    R R .V n         R V n        R # r'   )*_ModeStackStateForPreDispatch__infra_modes_schema_check_moder,   s   &r"   r.   &_ModeStackStateForPreDispatch.__init__d  s    "D\"&r0   c                    V\        V P                  4      8  d%   \        R V R\        V P                  4       24      hW P                  V&   R# )index & out of bounds for infra_modes length NlenrO  r[   )r-   indexrt   s   &&&r"   set!_ModeStackStateForPreDispatch.seth  sO    C**++ Ec$J\J\F]E^_  %)5!r0   c                    V\        V P                  4      8  d%   \        R V R\        V P                  4       24      hV P                  V,          # )rS  rT  rU  )r-   rW  s   &&r"   get!_ModeStackStateForPreDispatch.geto  sR    C**++ Ec$J\J\F]E^_  !!%((r0   c                    \        V P                   Uu. uF
  qf   K  VNK  	  up4      \        V P                  R J4      ,           # u upi r'   )rV  rO  intrP  )r-   is   & r"   count#_ModeStackStateForPreDispatch.countv  sF    t11C1!AA1CDs##4/H
 
 	
Cs
   AA)__infra_modesrP  N)
r   r   r   r   r.   rX  r[  r`  r   r   r   s   @r"   rM  rM  c  s     '))
 
r0   rM  c                   a a \        4       o\        P                  P                  P                  \        P                  P                  P
                  3pS e   S V9  d   \        RV RS  24      hV'       d   S e   \        R4      hVV 3R lpV! 4       p\        4       pV^ 8X  d/   \        P                  P                  \        P                  R4       V# )Nz mode_key must be None or one of z, got z/mode_key must be None when schema_check is Truec                    < S\         P                  P                  P                  J d.   SP	                  ^ 4      p \        4       P                  ^ R4       V # S\         P                  P                  P                  J d.   SP	                  ^4      p \        4       P                  ^R4       V # \        4       P                  p R\        4       n        V # )r   N)	r?   r@   _TorchDispatchModeKeyPROXYr[  !mode_stack_state_for_pre_dispatchrX  
FUNCTIONALrP  )current_modecurrent_mode_stack_pre_dispatchmode_keys    r"   _unset_mode,unset_mode_pre_dispatch.<locals>._unset_mode  s     uxx55;;;:>>qAL-/33At<77BBB:>>qAL-/33At<<>QQLEI-/Br0   F)rg  r?   r@   re  rf  rh  r[   r  '_dispatch_tls_set_dispatch_key_includedr   r  )rk  schema_check
valid_keysrl  ri  new_pre_dispatch_lenrj  s   f&    @r"   unset_mode_pre_dispatchrr    s    &G&I#&&,,&&11J 
 :.zl&
K
 	
  !RSS   =LAC
 q 889P9PRWXr0   c                    ^ RI Hp ^ RIHp ^ RIHp \        V VVV34      '       g   \        R\        V 4       24      h\        4       p\        W4      '       d7   \        4       P                  pV^ 8  d   \        R4      hV \        4       n        M\        W4      '       dG   \        4       P                  ^4      pVe   \        RV 24      h\        4       P                  ^V 4       ME\        4       P                  ^ 4      pVe   \        RV 24      h\        4       P                  ^ V 4       V^ 8X  d1   \        P                  P!                  \"        P$                  R	4       R# R# )
r   )ri   )SchemaCheckMode)ProxyTorchDispatchModezSmode must be FunctionalTensorMode, ProxyTorchDispatchMode, or SchemaCheckMode, got zYSchemaCheckMode for pre-dispatch must be used exclusively, found other modes on the stackNz.FunctionalTensorMode slot already occupied by z0ProxyTorchDispatchMode slot already occupied by T)r|   ri   #torch._subclasses.schema_check_modert  "torch.fx.experimental.proxy_tensorru  r]   r[   rK   r  rg  rP  r[  rX  r?   r@   rn  r   r  )rt   ri   rt  ru  previous_mode_stack_lenri  s   &     r"   _set_mode_pre_dispatchry    sV   HCI "	
  abfgkblamn
 	
 EF$((8:MM"Q& k  BF)+>	D	/	/8:>>qA# @O  	*+//488:>>qA# B<.Q  	*+//48 !#889P9PRVW $r0   c                     \        4       p \        4       pV^ 8X  d   \        R4      hV P                  e   \	        RRR7      # V P                  ^4      e.   \	        \        P                  P                  P                  4      # V P                  ^ 4      e.   \	        \        P                  P                  P                  4      # R# )r   zTrying to pop empty mode stackNT)ro  )rg  r  r[   rP  rr  r[  r?   r@   re  rh  rf  )
mode_stackpre_dispatch_lens     r"   _pop_mode_from_pre_dispatchr}    s    24J=?1=>>$$0&t$??~~a$&uxx'E'E'P'PQQ~~a$&uxx'E'E'K'KLL %r0   c                  2    \        4       P                  4       # r'   )rg  r`  rc   r0   r"   r  r    s    ,.4466r0   c                 "   V \         P                  P                  P                  J d   \	        4       P                  ^ 4      # V \         P                  P                  P                  Jd   \        RV  24      h\	        4       P                  ^4      # )r   z*mode_key must be PROXY or FUNCTIONAL, got )r?   r@   re  rf  rg  r[  rh  r[   )rk  s   &r"   _get_dispatch_mode_pre_dispatchr    ss    588117770266q9958899DDD <XJG  1266q99r0   c                  r   \        4       P                  e   \        4       P                  # \        4       P                  4       p V ^8X  d   \        4       P                  ^4      # V ^8X  dN   \        4       P                  ^4      e   \        4       P                  ^4      # \        4       P                  ^ 4      # R # r'   )rg  rP  r`  r[  )	stack_lens    r"   r  r    s    (*==I02EEE57==?	>46::1==> 56::1=I 2377: 78<<Q?
 r0   c                      \         # r'   )"_mode_stack_state_for_pre_dispatchrc   r0   r"   rg  rg  	  s    --r0   c                 0    \         P                  V 4       R # r'   )
cached_opsr   )op_overloads   &r"   add_cached_opr    s    NN;r0   c                  .    \         P                  4        R # r'   )r  r\   rc   r0   r"   reset_cached_opsr    s    r0   c                      \         # r'   )r  rc   r0   r"   get_cached_opsr    s    r0   c                     a a ] tR tRt oV3R lV 3R llt]V3R lR l4       t]V3R lR l4       t]V3R lR	 l4       tR%R
 lt	R t
V3R lR ltV3R lR ltR tR tV3R lV 3R lltV3R lV 3R llt]V3R lR l4       tV3R lR ltV3R lR ltV3R lR ltV3R lR ltR  t]R! 4       t]R" 4       t]R# 4       tR$tVtV ;t# )&
OpOverloadi"  c                   < V ^8  d   QhRRRS[ S[S[3,          RS[ S[S[S[3,          S[3,          RS[P                  P                  RS[S[	,          RR/# )	rH   overloadpacketOpOverloadPacketr   op_dkr   tagsrI   N)
r   r   r   r   r   r?   r@   FunctionSchemar  r   )rM   rN   s   "r"   rO   OpOverload.__annotate__#  sq     *= *=**= RV*= KO4b89	*=
 ''*= 3i*= 
*=r0   c                  < \         SV `  4        W n        W0n        W@n        Wn        WPn        VP                  R 8X  d   RMVP                  V n        V'       d#   \        P                  P                  V9   V n        V P                  P                  V n        VP                  '       d+   V ;P                  RVP                  ,           ,          un        V P                  P                  P                  R4      ^,           RV P                   2V n        VP"                  V n        VP"                  Vn        V P                  V n        / V n        V P$                  \        P(                  P*                  9   V n        RpV P                  P.                   FO  pVP0                  f   K  Vf   VP0                  P2                  pK/  VP0                  P2                  ;'       g    TpKQ  	  VRJ;'       d    V'       * V n        R# ) r   r   ::N)r   r.   _op_op_dk_schema_overloadpacket_tagsoverload_name_overloadnamer?   Tagnondeterministic_seeded_nondeterministic_seededr`   r   splitr   r   r   __annotations__library_defs_defined_in_pythonr   
alias_infor   is_view)	r-   r  r   r  r   r  r   r  r   s	   &&&&&&  r"   r.   OpOverload.__init__#  s    	-
--3I9M9M 	 ,1II,M,MQU,UD)\\&&
JJ# 4 444J<<,,2248;<Ad>P>P=QR(33&11 JJ! #'"3"3u}}7J7J"J ''A||#<<00 <<00<<H (  t+<<Hr0   c                    < V ^8  d   QhRS[ /# r   str)rM   rN   s   "r"   rO   r  P  s     < <C <r0   c                ^    V P                   P                  P                  R ^R7      ^ ,          # r  )maxsplitr  r`   r  r,   s   &r"   
_namespaceOpOverload._namespaceO  '    ||  &&ta&8;;r0   c                    < V ^8  d   QhRS[ /# r   r  )rM   rN   s   "r"   rO   r  T  s     < < <r0   c                ^    V P                   P                  P                  R ^R7      ^,          # r  r  r,   s   &r"   _opnameOpOverload._opnameS  r  r0   c                H   < V ^8  d   QhRS[ P                  P                  /# r   )r?   r@   _DispatchOperatorHandle)rM   rN   s   "r"   rO   r  X  s     
 
99 
r0   c                    \         P                  P                  V P                  P                  V P                  P
                  4      # r'   )r?   r@   _dispatch_find_schema_or_throwr  r`   r  r,   s   &r"   _handleOpOverload._handleW  s2    xx66LLt||99
 	
r0   c                    V # r'   rc   r3  s   &&r"   r5  OpOverload.__deepcopy__^  r7  r0   c                V    R V P                    RV P                   RV P                   R2# )z<OpOverload(op='r   z', overload='z')>)r  r  r  r,   s   &r"   __repr__OpOverload.__repr__a  s.    !$//!2!DLL>tOaOaNbbeffr0   c                T   < V ^8  d   QhRS[ P                  RS[ P                  RS[/# rm   rn   )rM   rN   s   "r"   rO   r  f  s*     ) ) )BII )" )r0   c               &    V P                   ! V/ VB # r'   r  r4   s   "*,r"   r7   OpOverload.__call__f  s    xx(((r0   c                   < V ^8  d   QhRS[ P                  P                  RS[P                  RS[P
                  RS[/# )rH   keysetr5   r6   rI   )r?   r@   DispatchKeySetr   r5   r6   r   )rM   rN   s   "r"   rO   r  k  sE     F F00F9;FLNIIF	Fr0   c               B    V P                   P                  ! V.VO5/ VB # r'   )r  redispatch_boxed)r-   r  r5   r6   s   "&*,r"   
redispatchOpOverload.redispatchk  s#     ||,,VEdEfEEr0   c                ,    \        V P                  4      # r'   hashr  r,   s   &r"   __hash__OpOverload.__hash__p      DHH~r0   c                    R P                   ! . V P                  P                  P                  R4      OV P                  N5!  # )z{}.{}.{}r  )rM   r  r`   r  r  r,   s   &r"   r,  OpOverload.__str__t  s6      T$,,"3"3"9"9$"?TASASTTr0   c                &   < V ^8  d   QhRS[ RS[/# rG   )r   r   )rM   rN   s   "r"   rO   r  w  s     L L[ LT Lr0   c                   < \         SV `  V4      ;'       g/    \        P                  P	                  V P                  4       V4      # r'   )r   r<   r?   r@   %_dispatch_has_kernel_for_dispatch_keyr`   r   s   &&r"   r<   &OpOverload.has_kernel_for_dispatch_keyw  s?    w2
 L LXX;;DIIKK	Lr0   c                N   < V ^8  d   QhRS[ P                  P                  RS[/# )rH   rC   rI   )r?   r@   r  r   )rM   rN   s   "r"   rO   r  |  s%     9 9%((2I2I 9d 9r0   c                   < \         P                  P                  V P                  4       V4      ;'       g    \        SV `  V4      # r'   )r?   r@   )_dispatch_has_kernel_for_any_dispatch_keyr`   r   rD   )r-   rC   r   s   &&r"   rD   *OpOverload.has_kernel_for_any_dispatch_key|  s<    xxAAIIK
 9 9W4R8	9r0   c                    < V ^8  d   QhRS[ /# r   r  )rM   rN   s   "r"   rO   r    s      3 r0   c                    V P                   # r'   )r  r,   s   &r"   r   OpOverload.namespace  s    r0   c                    < V ^8  d   QhRS[ /# r   r   )rM   rN   s   "r"   rO   r    s     
 
 
r0   c                    \         P                  pWP                  9   ;'       g/    \        P                  P                  V P                  4       V4      # r'   )r   r   r)   r?   r@   r  r`   )r-   dks   & r"   _can_decomposeOpOverload._can_decompose  sB    22__$ 
 
(V(VIIK)
 	
r0   c                T   < V ^8  d   QhRS[ P                  RS[ P                  RS[/# rm   rn   )rM   rN   s   "r"   rO   r    s*     " "rww "")) " "r0   c                   \         P                  pW0P                  9   d   V P                  V,          ! V/ VB # \        P                  P                  V P                  4       V4      '       d   V P                  ! V.VO5/ VB # \        # r'   )	r   r   r)   r?   r@   r  r`   r  r}   )r-   r5   r6   r  s   &*, r"   	decomposeOpOverload.decompose  sn    22 
 ??2&777XX;;DIIKLL;;r3D3F33!!r0   c                $   < V ^8  d   QhRS[ RR/# )rH   keyrI   Nr   )rM   rN   s   "r"   rO   r    s     , ,[ ,T ,r0   c                >    V P                   P                  VR 4       R # r'   )r(   pop)r-   r  s   &&r"   _uncache_dispatchOpOverload._uncache_dispatch  s      d+r0   c                L   < V ^8  d   QhRS[ RS[ S[S[S[3,          ,          /# rH   r  rI   )r   r   r   r   )rM   rN   s   "r"   rO   r    s-     _ _ _xB?O1O _r0   c                  a a SS P                   9   d   \        S  R S R24      hS\        P                  8X  dk   \	        S \
        4      '       g/   S P                  '       g   SS P                   S&   \        S 4       S# R VV 3R llpVS P                   S&   \        S 4       V# \        P                  P                  S4      pV\        P                  8X  dP   \        4       pV^ 8  d?   \        P                  P                  \        P                  4      '       g   R V 3R llpV# \        S S4      pS\        P                  8g  pS\        P                  8X  dR   ^ RIHu Hp VP&                  '       d7   VP)                  S V4      pV'       d   VS P                   S&   \        S 4       V# S P*                  P-                  WU4      pV'       d   VS P                   S&   \        S 4       V# ) z already in dispatch cachec                d    V ^8  d   QhR\         P                  R\         P                  R\        /# rm   rn   )rM   s   "r"   rO   .OpOverload._get_dispatch.<locals>.__annotate__  s.     S Srww S")) S Sr0   c                    < ^ RI Hp \        V! 4       4      pVf   \        R4      hVSP                  9  d   \        S\        4      '       dk   \        P                  P                  P                  4       ;_uu_ 4       p\        P                  P                  P                  ! VS.V O5/ VB uuRRR4       # SP                  ! S.V O5/ VB # \        P                  P                  P                  4       ;_uu_ 4       pSP                  V,          ! V.V O5/ VB uuRRR4       #   + '       g   i     Lh; i  + '       g   i     R# ; i)r   r   NzDIllegal invocation of dispatch on DispatchKey.Python without a mode.)r  r   rK   r[   r*   r]   TorchBindOpOverloadr?   utils_python_dispatchr   _libraryhandle_dispatch_moder  )r5   r6   r   r  rt   r  r-   s   *,   r"   r  )OpOverload._get_dispatch.<locals>.handler  s   S !!;!=>	$(^  D$9$99!$(;<<!KK88NNPPTX#(>>#7#7#L#L $d$-1$5;$ QP  ${{3@@@@[[11GGIIT00;DR4R6R JI QP JIIs   >/D&>D9&D6	9E
	c                d    V ^8  d   QhR\         P                  R\         P                  R\        /# rm   rn   )rM   s   "r"   rO   r    s)      277 bii B r0   c                     < \         P                  R  4       pV! 4       ;_uu_ 4       p\        P                  P                  P
                  ! VS.V O5/ VB uuRRR4       #   + '       g   i     R# ; i)c               3   b   "   \        4       p  V x  \        V 4       R #   \        T 4       i ; i5ir'   )r}  ry  )top_modes    r"   (_temporarily_pop_modes_from_pre_dispatch[OpOverload._get_dispatch.<locals>.handler.<locals>._temporarily_pop_modes_from_pre_dispatch  s(     #>#@="*N28<28<s   / /,/N)
contextlibcontextmanagerr?   r  r  r  )r5   r6   r  r  r-   s   *,  r"   r  r    sf    ..= /= BCCy$~~33HH%t .2 6<  DCCCs   /A!!A2	N)r(   r[   r   r^   r]   r  r*   r  r?   r@   r  r  r  r  r   r   torch._dispatch.python	_dispatchpythonCROSSREF_FUNCTIONALIZEmake_crossref_functionalizer)   r[  )	r-   r  r  r  curr_stack_lenr  cache_result
pydispatchrs	   ff       r"   _get_dispatchOpOverload._get_dispatch  s   $&&& D63%/I!JKK+$$$d$788AVAVAV,/$$S)d#
S S2 )0D  %$N!HH::3? 7 77CEN "GG&& 
 & c*	 k555
 ++++77000$@@yQ07D((-!$'OO	5()D  %$r0   c                    V P                   # r'   r/  r,   s   &r"   r`   OpOverload.name  r1  r0   c                    V P                   # r'   )r  r,   s   &r"   r  OpOverload.overloadpacket  s    ###r0   c                    V P                   # r'   r  r,   s   &r"   r   OpOverload.op  r   r0   c                    V P                   # r'   )r  r,   s   &r"   r  OpOverload.tags  s    zzr0   )r  r   r   r   r  r   r  r  r  r  r  r  r  r  r'   )r   r   r   r   r.   r   r  r  r  r5  r  r7   r  r  r,  r<   rD   r8  r   r  r  r  r  r`   r  r   r  r   r   r;  r<  s   @@r"   r  r  "  s    *= *=X < < < < 
 
g
) )
F F
UL L
9 9
  
 
" "*, ,_ _B $ $     r0   r  c                   V   a  ] tR tRt o V 3R lR ltV 3R lR ltV 3R lR ltRtV tR	# )
r  i  c                0   < V ^8  d   QhRS[ S[,          /# r   )r  r   )rM   rN   s   "r"   rO    TorchBindOpOverload.__annotate__  s     
 
4#4 
r0   c                X  a  \         P                  \         P                  \         P                  \         P                  \         P
                  \         P                  \         P                  \         P                  .pR  V 3R llpV Uu. uF  pV! V4      '       g   K  VNK  	  up# u upi )c                $    V ^8  d   QhR\         /# )rH   r  r  )rM   s   "r"   rO   ;TorchBindOpOverload._fallthrough_keys.<locals>.__annotate__*  s     		 		+ 		r0   c                 P  < \         P                  P                  SP                  4       V 4      '       d/   \         P                  P	                  SP                  4       V 4      # V SP
                  9  ;'       g.    SP
                  V ,          \         P                  P                  J # r'   )r?   r@   r  r`   0_dispatch_kernel_for_dispatch_key_is_fallthroughr)   r  fallthrough_kernel)r  r-   s   &r"   (_may_use_fallthrough_instead_of_fallbackWTorchBindOpOverload._fallthrough_keys.<locals>._may_use_fallthrough_instead_of_fallback*  s|    xx==diik3OOxxPPIIK 
 4??* L L??3'5==+K+KKr0   )	r   r   AutogradCPUAutogradCUDAADInplaceOrViewBackendSelectPythonTLSSnapshotPythonDispatcherr   )r-   _DEFAULT_FALLTHROUGH_KEYSr#  r  s   f   r"   _fallthrough_keys%TorchBindOpOverload._fallthrough_keys  s       ##$$''%%))((%%	%
!		 		 1
07< C0
 	
 
s   	B'B'c                T   < V ^8  d   QhRS[ P                  RS[ P                  RS[/# rm   rn   )rM   rN   s   "r"   rO   r  =  s*     ) ) )BII )" )r0   c                   \        W4      '       d%   V P                  ! V P                  4       .VO5/ VB # V P                  ! V/ VB # r'   )_must_dispatch_in_python_dispatch_in_pythonr,  r  r4   s   "*,r"   r7   TorchBindOpOverload.__call__=  sG    #D11 ++D,B,B,DVtVvVVxx(((r0   c                j   < V ^8  d   QhRS[ S[,          RS[P                  RS[P                  RS[/# )rH   fallthrough_keysr5   r6   rI   )r  r   r   r5   r6   r   )rM   rN   s   "r"   rO   r  E  s:     (( (( $[ 1((:<''((MOYY((	((r0   c           	     t   \         P                  P                  4       pV F  pVP                  V4      pK  	  \	        W#V4      pVP                  4       pWpP                  9  d   V P                  V4      MV P                  V,          p\        V\        4      '       dg   \         P                  P                  V P                  4       V4      '       d   V P                  ! W.,           .VO5/ VB # \        R V  RV RV R24      h\        V\        4      '       g   \        R\!        V4       24      hV! V/ VB # )zTorchbind op z4 received a FakeScriptObject input when dispatching z. but no python implementation is found. Please file an issue on this when you encounter this error. This error can happen when you export or compile the model. It can still happen even if a C++ implementation for zz.  has been registered. That's because FakeScriptObject purely lives in python and cannot work  with a C++ implementation.zhandler must be callable, got )r?   r@   r   r   r$  r%  r(   r  r]   r   r!  r`   r1  r_   r   r[   rK   )	r-   r4  r5   r6   r   r  r'  r   r  s	   &&*,     r"   r1  'TorchBindOpOverload._dispatch_in_pythonE  sS     %xx==?#C#7#>#>s#C  $ +49MN'==? #7#77 |,%%l3 	 g{++ xxHH		\  //$~5   v%YZaYb cI JV W.	/  '8,, #A$w-!QRR'''r0   rc   N)	r   r   r   r   r,  r7   r1  r   r   r   s   @r"   r  r    s$     
 
B) )(( ((r0   r  c                $    V ^8  d   QhR\         /# r   r   )rM   s   "r"   rO   rO   p  s       r0   c                   \        V \        P                  P                  P                  4      '       d   R# \        V \
        \        34      '       d5   \        ;QJ d    R V  4       F  '       g   K   R# 	  R# ! R V  4       4      # \        V \        4      '       dQ   \        ;QJ d*    R V P                  4        4       F  '       g   K   R# 	  R# ! R V P                  4        4       4      # R# )zCheck if obj is or contains a FakeScriptObject.
This is load-bearing for TorchBindOpOverloads so we avoid pytree
since it's much slower.
Tc              3   8   "   T F  p\        V4      x  K  	  R # 5ir'   _contains_fake_script_object)r   items   & r"   r   /_contains_fake_script_object.<locals>.<genexpr>x  s     F#$/55#r   Fc              3   8   "   T F  p\        V4      x  K  	  R # 5ir'   r:  r   vs   & r"   r   r=  z  s     ILq/22Lr   )
r]   r?   r  fake_class_registryFakeScriptObjectr  r  r   dictr  )objs   &r"   r;  r;  p  s    
 #u~~99JJKK	C$	'	'sF#FssFsFsF#FFF	C		sICJJLIssIsIsICJJLIIIr0   c                $    V ^8  d   QhR\         /# r   r   )rM   s   "r"   rO   rO   ~  s      d r0   c                 @   \         ;QJ d    R  V  4       F  '       g   K   RM	  RM! R  V  4       4      ;'       gd    \        V4      ;'       dQ    \         ;QJ d*    R VP                  4        4       F  '       g   K   R# 	  R# ! R VP                  4        4       4      # )c              3   8   "   T F  p\        V4      x  K  	  R # 5ir'   r:  r   s   & r"   r   +_must_dispatch_in_python.<locals>.<genexpr>  s     ADS+C00Dr   TFc              3   8   "   T F  p\        V4      x  K  	  R # 5ir'   r:  r?  s   & r"   r   rH    s     Vo9!<<or   )r   r   r  r?  s   &&r"   r0  r0  ~  ss    3ADA333ADAA  VVVVfmmoVVfmmoVVr0   c                D    V ^8  d   QhR\         P                  R\        /# )rH   r   rI   )r?   r  r   )rM   s   "r"   rO   rO     s$     R R5#7#7 RD Rr0   c                     \         ;QJ d&    R  V P                   4       F  '       g   K   R# 	  R# ! R  V P                   4       4      # )c              3   j   "   T F)  p\        VP                  \        P                  4      x  K+  	  R # 5ir'   )r]   rK   r?   	ClassTyper   s   & r"   r   )_has_script_object_arg.<locals>.<genexpr>  s$     Q@Pz#((EOO44@Ps   13TF)r   r   )r   s   &r"   _has_script_object_argrO    s7    3Q@P@PQ33Q3Q3Q@P@PQQQr0   c                      a  ] tR tRt o RtV 3R lR ltRR ltR tR tR	 t	]
R
 4       t]
R 4       tV 3R lR ltV 3R lR ltV 3R lR ltR tV 3R ltRtV tR# )r  i  	torch.opsc          
      \   < V ^8  d   QhRS[ RS[ RS[S[S[3,          RS[S[ ,          RR/# )rH   qualified_op_nameop_namer   overload_namesrI   N)r  r   r   r   r  )rM   rN   s   "r"   rO   OpOverloadPacket.__annotate__  sJ     
 

 
 RV	

 S	
 

r0   c                2   Wn         W n        W0n        W@n        . V n        \
        ;QJ dB    R  V P                  P                  4        4       F  '       g   K   RV n        R# 	  RV n        R# ! R  V P                  P                  4        4       4      V n        R# )c              3   8   "   T F  p\        V4      x  K  	  R # 5ir'   )rO  )r   r   s   & r"   r   ,OpOverloadPacket.__init__.<locals>.<genexpr>  s      .
9Ov"6**9Or   TFN)	_qualified_op_namer   r  _overload_names_dirr   _schemasr  _has_torchbind_op_overload)r-   rS  rT  r   rU  s   &&&&&r"   r.   OpOverloadPacket.__init__  sv     #4-!	*-# .
9=9M9M9O.
##'#'# .
9=9M9M9O.
 +
'r0   Nc                    V # r'   rc   r3  s   &&r"   r5  OpOverloadPacket.__deepcopy__  r7  r0   c                T    R P                   ! V P                  P                  R4      !  # )z<OpOverloadPacket(op='{}.{}')>r  rM   rZ  r  r,   s   &r"   r  OpOverloadPacket.__repr__  s)    /66$$**40
 	
r0   c                ,    \        V P                  4      # r'   r  r,   s   &r"   r  OpOverloadPacket.__hash__  r  r0   c                T    R P                   ! V P                  P                  R4      !  # )z{}.{}r  rc  r,   s   &r"   r,  OpOverloadPacket.__str__  s"    ~~t66<<TBCCr0   c                    V P                   # r'   r  r,   s   &r"   r   OpOverloadPacket.op  r   r0   c                    V P                    Uu/ uF.  pV\        P                  P                  V P                  V4      bK0  	  up# u upi r'   )r[  r?   r@   _get_schemarZ  )r-   r  s   & r"   r]  OpOverloadPacket._schemas  sK     "&!5!5
!5 588//0G0GWW!5
 	
 
s   4Ac                <   < V ^8  d   QhRS[ RS[S[S[3,          /# r  )r  r  r   r   )rM   rN   s   "r"   rO   rV    s$     / /s /z"b&'9 /r0   c           
         VP                  R 4      '       d   \        V P                  V4      #   TR8X  d   RMTp\
        P                  P                  T P                  T4      pTf   \        R\	        T 4       R	T R24      hTw  rEp\
        P                  P                  T P                  T4      p\        T4      '       g   \        YYWT4      M\        YYWT4      p\        YT4       T P                  P                  T4       T#   \         d4    \        R\	        T 4       R\	        T P                  4       RT R24      Rhi ; i  \          d    \        R\	        T 4       R	T R24      Rhi ; i)
__'zH' can't have an overload name beginning with '__' and the underlying op z has no attribute z either.Nr   r  zThe underlying op of 'z' has no overload name ')
startswithgetattrr  AttributeErrorr  r?   r@   _get_operation_overloadrZ  rl  rO  r  r  setattrr\  r   r_   )	r-   r  use_key
op_dk_tagsop_op_dk_r  r   overloads	   &&       r"   __getattr__OpOverloadPacket.__getattr__  s   	~~d##txx-- $	9,b#G99''J !$,SYK7OPSuTUV  !+CXX))$*A*A7KF .f55 4fd;(FDI  Dx(IIS!OA  	
 !CI; !!$TXX/A#hP 	B  	 (T3KC5PQR	s   D D CE	 >E	(E1c                0   < V ^8  d   QhRS[ S[,          /# r   r   r  )rM   rN   s   "r"   rO   rV          (3- r0   c                ,    \        V P                  4      # r'   iterr\  r,   s   &r"   __iter__OpOverloadPacket.__iter__      DIIr0   c                T   < V ^8  d   QhRS[ P                  RS[ P                  RS[/# rm   rn   )rM   rN   s   "r"   rO   rV    s*     ) ) )BII )" )r0   c                   V P                   '       d!   \        W4      '       d   \        V .VO5/ VB # V P                  ! V/ VB # r'   )r^  r0  !_call_overload_packet_from_pythonr  r4   s   "*,r"   r7   OpOverloadPacket.__call__  sD     ***/G/U/U4TKDKFKKxx(((r0   c                V    V P                    Uu. uF  q'       d   TMR NK  	  up# u upi r   )r[  )r-   ns   & r"   	overloadsOpOverloadPacket.overloads  s)    /3/C/CD/C!QI%/CDDDs   &c                6   < V ^8  d   Qh/ S[ S[,          ;R&   # )rH   __file__)r   r  )rM   rN   s   "r"   rO   rV    s     sm) r0   )r   r\  r^  r  r[  rZ  r'   )r   r   r   r   r  r.   r5  r  r  r,  r8  r   r]  r|  r  r7   r  __annotate_func__r   r   r   s   @r"   r  r    s~     )H
 
&

D   
 
/ /b 
) )Ei  r0   r  c                    V ^8  d   QhR\         \        \        3,          R\        P                  R\        P                  R\        /# )rH   r   r5   r6   rI   )r  r   r   r5   r6   )rM   s   "r"   rO   rO     s=     %  % R % )+% <>II% % r0   c                    \         P                  P                  ! V .VO5/ VB w  r4V'       d   V# / pR pV P                  4        F?  p\	        W4      p \         P                  P
                  ! VP                  .VO5/ VB p	Tp M	  V'       d	   V! V/ VB # RV  R2pVP                  4        F  w  rVRV RV R2,          pK  	  \        V4      h  \         d   p
YT&    R p
?
K  R p
?
ii ; i)Nz'Fail to match any TorchBindOverload of z with following exceptions:
zOverload name z:
 
)	r?   r@   (_maybe_call_torch_function_for_op_packetr  rs  &_check_schema_allow_fake_script_objectr  r_   items)r   r5   r6   torch_function_calledret
exceptionsfound_opr  r  _eerr_msgr  msgs   &*,           r"   r  r    s    "'!R!R
""" 
 JHb0	*??##&*.4A #H ( ((( 2"5RS  $$&^C5SE44 '
w
  	*()}%	*s   0CC,C''C,c                   j   a a ] tR tRt oRtRtV3R lV 3R lltV3R lR ltV3R lR	 ltR
t	Vt
V ;t# )_OpNamespacei;  a  
An op namespace to dynamically bind Operators into Python.

Say a user has created a custom Operator called "my_namespace::my_op". To
call this op, the user will write torch.ops.my_namespace.my_op(...).
At startup, this operation will not yet be bound into Python. Instead, the
following sequence of magic tricks will occur:
1. `torch.ops.my_namespace` will invoke the `__getattr__` magic method
   on the `torch.ops` object, which will create a new `_OpNamespace`
   object called `my_namespace` and set it as an attribute on the `ops`
   object.
2. `torch.ops.my_namespace.my_op` will then invoke `__getattr__` on
   the `my_namespace` object, which will retrieve the operation via
   `torch.get_operation`, a function bound from C++, and then in a similar
   fashion bind this new object onto the `my_namespace` object.
3. `torch.ops.my_namespace.my_op(...)` then calls this new operation
    and subsequent accesses will incur no further lookup (the namespace and
    operation will already exist).
rQ  c                $   < V ^8  d   QhRS[ RR/# )rH   r`   rI   Nr  )rM   rN   s   "r"   rO   _OpNamespace.__annotate__R  s     " "S "T "r0   c                N   < \         SV `  R V,           4       Wn        . V n        R# )z
torch.ops.N)r   r.   r`   r\  )r-   r`   r   s   &&r"   r.   _OpNamespace.__init__R  s!    ,-	!	r0   c                0   < V ^8  d   QhRS[ S[,          /# r   r  )rM   rN   s   "r"   rO   r  W  r  r0   c                ,    \        V P                  4      # r'   r  r,   s   &r"   r  _OpNamespace.__iter__W  r  r0   c                &   < V ^8  d   QhRS[ RS[/# )rH   rT  rI   )r  r  )rM   rN   s   "r"   rO   r  Z  s     "  " 3 " +; " r0   c                   VR	9   d   \        RV RV P                   R24      hV P                  pV RV 2pV P                  R,           V,           p \        W44      w  rVVf   \        RV P                   RV R24      h YEn        \        Y1YV4      pT P                  R,           T,           Tn        \        YT4       T P                  P                  T4       T#   \         d#   p\        RT P                   RT R24      ThRp?ii ; i)

__origin__zInvalid attribute 'z' for '_OpNamespace' 'rq  r  r   Nz'_OpNamespace' 'z' object has no attribute ')r  __self__)	rt  r`   r   _get_packetr_   r  rv  r\  r   )	r-   rT  namespace_namerS  module_namer   rU  r  opoverloadpackets	   &&       r"   r|  _OpNamespace.__getattr__Z  s2   00 %gY.DTYYKqQ  -.b	:oo+n<	!,->!LBz$&tyyk1LWIUVW   $+
 '+oo&;n&L# 	/0		!!  	 !"499+-H	QRS	s   -C D%DD)r\  r`   )r   r   r   r   r   r  r.   r  r|  r   r   r;  r<  s   @@r"   r  r  ;  s4     ( H" "
 "  "  " r0   r  c                     \         P                  P                  V 4      w  r#Ve0   \         P                  P                  P                  W 4       Wn        W#3# r'   )r?   r@   _jit_get_operationjit	_builtins_register_builtinr   )qualname	op_moduler   rU  s   &&  r"   r  r    sF    44X>B	~ 			--b;!r0   c                     \        V P                  V P                  P                  4      w  rVf   \	        RV P                   24      hWn        W n        R # )Nzfailed to get packet for )r  rZ  r  r   r[   r[  )packetr   rU  s   &  r"   _refresh_packetr    sK    $V%>%>

@U@UVB	z89R9R8STUUJ+r0   c                   f   a a ] tR tRt oRtV3R lV 3R lltV3R lR ltV3R lR ltR	tVt	V ;t
# )
_HigherOrderNamespacei  rQ  c                   < V ^8  d   QhRR/# )rH   rI   Nrc   )rM   rN   s   "r"   rO   "_HigherOrderNamespace.__annotate__  s     " "$ "r0   c                4   < \         SV `  R 4       . V n        R# )r   N)r   r.   r\  r-   r   s   &r"   r.   _HigherOrderNamespace.__init__  s    12!	r0   c                0   < V ^8  d   QhRS[ S[,          /# r   r  )rM   rN   s   "r"   rO   r    r  r0   c                ,    \        V P                  4      # r'   r  r,   s   &r"   r  _HigherOrderNamespace.__iter__  r  r0   c                &   < V ^8  d   QhRS[ RS[/# rH   r`   rI   )r  r   )rM   rN   s   "r"   rO   r    s     	 	 	(; 	r0   c                    \         P                  V4      pVf   \        RV R24      h\        WV4       V P                  P                  V4       V# )NzJ'_HigherOrderNamespace' 'torch.ops.higher_order' object has no attribute 'rq  )r   r[  rt  rv  r\  r   )r-   r`   r   s   && r"   r|  !_HigherOrderNamespace.__getattr__  sV    ""4(: \]a\bbcd  	B			r0   )r\  )r   r   r   r   r  r.   r  r|  r   r   r;  r<  s   @@r"   r  r    s-     H" " 	 	 	r0   r  c                   f   a a ] tR tRt oRtV 3R ltV3R lR ltV3R lR ltR tR	 t	R
t
VtV ;t# )_Opsi  z_ops.pyc                p   < \         SV `  R 4       \        4       V n        \	        4       V n        . V n        R# )rQ  N)r   r.   rX  loaded_librariesr  r   r\  r  s   &r"   r.   _Ops.__init__  s,    % #13	r0   c                &   < V ^8  d   QhRS[ RS[/# r  )r  r  )rM   rN   s   "r"   rO   _Ops.__annotate__  s        r0   c                j    \        V4      p\        WV4       V P                  P                  V4       V# r'   )r  rv  r\  r   )r-   r`   r   s   && r"   r|  _Ops.__getattr__  s.     &	I&		r0   c                0   < V ^8  d   QhRS[ S[,          /# r   r  )rM   rN   s   "r"   rO   r    r  r0   c                ,    \        V P                  4      # r'   r  r,   s   &r"   r  _Ops.__iter__  r  r0   c                2    \         P                  ! V4       R# )a#  
Imports a Python module that has torch.library registrations.

Generally, to extend PyTorch with custom operators, a user will
create a Python module whose import triggers registration of
the custom operators via a torch.ops.load_library call or a call
to one or more torch.library.* APIs.

It is unexpected for Python modules to have side effects, so some
linters and formatters will complain. Use this API to import Python
modules that contain these torch.library side effects.

Args:
    module (str): The name of the Python module to import

N)	importlibimport_module)r-   modules   &&r"   r  _Ops.import_module  s    " 	'r0   c                8   \         P                  ! V4      p\        4       ;_uu_ 4         \        P                  ! V4        RRR4       T P                  P                  T4       R#   \
         d   p\        RT 24      ThRp?ii ; i  + '       g   i     LO; i)a  
Loads a shared library from the given path into the current process.

The library being loaded may run global initialization code to register
custom operators with the PyTorch JIT runtime. This allows dynamically
loading custom operators. For this, you should compile your operator
and the static registration code into a shared library object, and then
call ``torch.ops.load_library('path/to/libcustom.so')`` to load the
shared object.

After the library is loaded, it is added to the
``torch.ops.loaded_libraries`` attribute, a set that may be inspected
for the paths of all libraries loaded using this function.

Args:
    path (str): A path to a shared library to load.
zCould not load this library: N)	r   resolve_library_pathr#   r   CDLL	ExceptionOSErrorr  r   )r-   pathr  s   && r"   load_library_Ops.load_library  sy    $ 33D9__MD!  	!!$'  M =dVDE1LM _s(   B	A''B2BBB		B	)r\  r   r  )r   r   r   r   r  r.   r|  r  r  r  r   r   r;  r<  s   @@r"   r  r    s2     H  (&( (r0   r  c                    V ^8  d   Qh/ ^ \         9   d   \        \        R3,          ;R&   ^\         9   d   \        R,          ;R&   ^\         9   d
   \        ;R&   # )rH   r   r   r  r  ops)__conditional_annotations__rC  r  rX  r  )rM   s   "r"   rO   rO      sR    

L 9 84223 8M X & %C %Y T/  T U/ r0   )F)`r  r9  r  r   r  rX   r   typescollections.abcr   r   	functoolsr   typingr   r   r   r	   r
   r   typing_extensionsr   r   r?   torch.utils._pytreer  _pytreer   r   torch._Cr   r   r   torch._functorch.pyfunctorchr   r   r  r   r   ImportErrorrK   r}   r|   r   r   r   hasattrr   r  r#   r%   r   r   r*  r)  r'  r(  AutocastCPUAutocastCUDAAutocastXPUr   ABCr   r   r$  rA  rB  rM  r  rr  ry  r}  r  r  r  rg  rX  r  r  r  r  r  r  r;  r0  rO  r  r  
ModuleTyper  r  r  r  r  r  rO   )r  s   @r"   <module>r     s]   

     
  . % L L 0  $ $ ! X J :.(
 H T3tS! C!12UUwsDT7U  & & V" V"t2Uj 79  8   !!6 2d, dN	38
,
 
2 &C%D "(V-X`M7	: .
 !$
 % 

pwr2v prR(*RV, R(jRuEwr2v uEt% nA 5## A H,E,, ,A(5 A(J F i.  .n-.s   3H1 1II