
    ȅiBk                     |   % S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	  S SK
rS SKJr  S SK
Jr  S SKJr  S SKJrJrJrJrJrJr  SSKJrJr   / SQrSS	S
.r1 SkrS r S,S\S\R<                  \   S\R>                  4S jjr 0 r!\"\S4   \#S'    " S S5      r$\ RJ                   " S S5      5       r&S\S\4S jr'S\SS4S jr(S\SS4S jr)S\S\*\\4   4S jr+S\SS4S jr,S \RZ                  S\.4S! jr/S\S"\R>                  SS4S# jr0S$\Rb                  S%\SS4S& jr2S' r3S( r4S-S) jr5S* r6S.S+ jr7g)/    N)infer_schema)get_ctx)BaseTyBaseTypeFunctionSchemaListTypeOperatorName
SchemaKind   )autograd_kernel_indirectionconstruct_autograd_kernel)	custom_opCustomOpr   CPUCUDA)cpucuda>   atatenprimprimstorchpytorchc                  8    [         R                  " S[        SS9  g )Nzwtorch._custom_op is deprecated and will be removed in PyTorch 2.6, please use the equivalent torch.library API instead.   
stacklevel)warningswarnDeprecationWarning     O/home/james-whalen/.local/lib/python3.13/site-packages/torch/_custom_op/impl.pywarn_deprecatedr$   5   s    MM	8	r"   qualnamemanual_schemareturnc                 ,   ^ ^ [        5         UU 4S jnU$ )D
This API is deprecated, please use torch.library.custom_op instead
c           	        > [         R                  " U 5      (       d  [        S[        U 5       35      e[	        T
5      u  p[        U5        U R                  U:w  a  [        ST
 SU SU R                   S35      eT	c
  [        U SS9OT	nU U 3n[        R                  " U5      n[        U5        T	b  [        XP5        [        R                  " US5      nUR                  U5        [        XR                   5      n[#        XaXRUS	S
9nU R                  Ul        U R$                  Ul        U R&                  Ul        [        R(                  " XhR*                  S5      " [-        [.        R0                  " U5      5      5        [2        R4                  R7                  U[8        R:                  " [<        [.        R0                  " U5      5      5        U$ )NzDcustom_op(...)(func): Expected `func` to be a Python function, got: zcustom_op(qualname='z-', ...)(func): expected `func` to have name 'z' but got 'zX'. Please either change the name of `func` or the qualname that is passed to `custom_op`r!   )mutates_argsFRAGMENTT_private_accessAutograd)inspect
isfunction
ValueErrortypeparse_qualnamevalidate_namespace__name__r   r   parsevalidate_schema validate_function_matches_schemalibraryLibrarydefinefind_ophandle_or_thrownamer   
__module____doc__impl_opnamer   weakrefproxyr   _C#_dispatch_set_report_error_callback	functoolspartialreport_error_callback)funcnsr>   schema
schema_strfunction_schemalibophandleresultr&   r%   s            r#   innercustom_op.<locals>.innerF   s   !!$''""&t*/ 
 "(+2==D &xj 1!!%k$-- A+,  $ B/ 	
 vfX&
(..z:($,_Coob*-

:)".B.BC_Hd
 -- OOS..*5'f(=>	
 	44i''(=w}}V?TU	
 r"   )r$   )r%   r&   rR   s   `` r#   r   r   >   s     /b Lr"   r   global_registryc                   @  ^  \ rS rSrSrSS.U 4S jjrS rSS jrS rS	 r	S
 r
S rS r SS\R                  \\R                   \   4   S\R"                  4S jjrS rS\R"                  4S jrSS\R"                  4S jjrS rS rS rS rSS jrSS jrSrU =r$ )r      r)   Fr-   c                   > [         TU ]  5         [        5         U(       d  [        S5      eU SU 3nX0l        X l        Xl        XPl        X@l        Xpl	        S U l
        0 U l        SU l        U [        U R                  '   g )Nz|The CustomOp constructor is private and we do not guarantee BC for it. Please use custom_op(...) to create a CustomOp object::F)super__init__r$   RuntimeError_schema_cpp_ns_lib	_ophandlerB   	_qualnamer6   _impls'_registered_autograd_kernel_indirectionrT   )	selfrO   cpp_nsrL   operator_namerP   r.   r>   	__class__s	           r#   rZ   CustomOp.__init__   s     	S  M?+%(	5=)" DF7<4*.'r"   c                     U R                   (       a  [        S5      eU R                  R                  U R                  [        [        R                  " U 5      5      S5        SU l         g )Nz.autograd kernel indirection already registeredr/   T)rb   AssertionErrorr^   rA   rB   r   rC   rD   rc   s    r#   %_register_autograd_kernel_indirection.CustomOp._register_autograd_kernel_indirection   sK    77 !QRR		LL5gmmD6IJJ	
 8<4r"   c                    U R                  U5      (       aK  U R                  U   nUc  [        S5      eUR                  n[	        SU SU R
                   SU SU S3	5      e[        R                  " [        R                  " U5      5      nUR                   SUR                   3n[        X%5      U R                  U'   g )Nz&func_and_location is unexpectedly NonezAttempting to register a z impl for operator z that already has a z  impl registered from Python at z. This is not supported.:)	_has_implra   ri   locationr[   r`   r0   getframeinfosys	_getframefilenamelinenoFuncAndLocation)rc   kindrJ   r   func_and_locationrp   frames          r#   _register_implCustomOp._register_impl   s    >>$ $D 1 ($%MNN(11H+D61DT^^DT U&&*V+K*46 
 $$S]]:%>?nn%Qu||n5+D;Dr"   c                      U R                   U   $ Nra   rc   rw   s     r#   	_get_implCustomOp._get_impl   s    {{4  r"   c                     XR                   ;   $ r}   r~   r   s     r#   ro   CustomOp._has_impl   s    {{""r"   c                     U ? [        [        R                  U R                  5      n[        XR                  5      (       a  [        XR                  5        [        U R                  	 g r}   )
r^   getattrr   opsr]   hasattrrB   delattrrT   r`   )rc   opnamespaces     r#   _destroyCustomOp._destroy   sD     Ieii6;--K.DNN+r"   c                 "    SU R                    S3$ )Nz<CustomOp(op="z")>)r`   rj   s    r#   __repr__CustomOp.__repr__   s    /s33r"   c                 N    [         R                  " U R                  /UQ70 UD6nU$ r}   )rE   _dispatch_call_boxedr_   )rc   argskwargsrQ   s       r#   __call__CustomOp.__call__   s'     ((I$I&Ir"   device_typesr'   c                 t   ^ ^^ [        T[        5      (       a  T/mT H  n[        U5        M     UUU 4S jnU$ )r)   c                    > [        T5       H_  nTR                  U5        TR                  XTS9  [        U   n[        R
                  " TR                  TR                  U5      " U 5        Ma     U $ )Nr   )set_check_doesnt_have_library_implrz   SUPPORTED_DEVICE_TYPE_TO_KEYr:   rA   r^   rB   )fdevice_typedispatch_key_stacklevelr   rc   s      r#   rR   CustomOp.impl.<locals>.inner   sa    "<044[A##K{#K;KHTYYlCAF	  1
 Hr"   )
isinstancestrvalidate_device_type)rc   r   r   r   rR   s   ```  r#   rA   CustomOp.impl   s7     lC(((>L'K - (	 r"   c                     U R                  U5      (       a  g [        U   n[        R                  " U R                  U5      (       a  [        SU SU R                   S35      eg )Nzimpl(..., device_types=z): the operator zs already has an implementation for this device type via a pre-existing torch.library or TORCH_LIBRARY registration.)ro   r   rE   ._dispatch_has_computed_kernel_for_dispatch_keyr`   r[   )rc   r   keys      r#   r   (CustomOp._check_doesnt_have_library_impl   sh    >>+&&*;7<<T^^SQQ)+6Ft~~FV WL M  Rr"   c                    ^  U 4S jnU$ )z2Register an implementation for a factory function.c                    > TR                  SU 5        [        R                  " TR                  TR                  S5      " U 5        U $ )NfactoryBackendSelect)rz   r:   rA   r^   rB   )r   rc   s    r#   rR   $CustomOp.impl_factory.<locals>.inner  s5    	1-LLDLL/B1EHr"   r!   )rc   rR   s   ` r#   impl_factoryCustomOp.impl_factory   s    	
 r"   c                    ^ ^ UU 4S jnU$ )r)   c                 .  >^ ^^ TR                  5         TR                  ST TS9  TR                  S5      R                  mTR                  m[
        R                  " T 5      U UU4S j5       nTR                  R                  TR                  US5        T $ )Nabstractr   c                     > UU4S jn[         R                  R                  R                  U5         T" U 0 UD6sS S S 5        $ ! , (       d  f       g = f)Nc                  &   > [        ST ST  35      e)Nz<Attempted to call get_ctx() for the meta implementation for a  .You have presumably called get_ctx() because the operator has a data-dependent output shape; if so, there is no such meta implementation and this error is the correct behavior. Otherwise, please remove the call to get_ctx() in the implementation registered with impl_abstract at r[   )rp   r%   s   r#   error_on_ctxOCustomOp.impl_abstract.<locals>.inner.<locals>.f_with_ctx.<locals>.error_on_ctx  s+    &'j ) 'Z)	 	r"   )r   _library	fake_implset_ctx_getter)r   r   r   r   rp   r%   s      r#   
f_with_ctx9CustomOp.impl_abstract.<locals>.inner.<locals>.f_with_ctx  s<    
 ^^--<<\Jd-f- KJJs   A
AMeta)
$_check_doesnt_have_library_meta_implrz   r   rp   r`   rG   wrapsr^   rA   rB   )r   r   rp   r%   r   rc   s   ` @@r#   rR   %CustomOp.impl_abstract.<locals>.inner  s}    557
A+F~~j1::H~~H __Q.  .  IINN4<<V<Hr"   r!   rc   r   rR   s   `` r#   impl_abstractCustomOp.impl_abstract	  s    
	8 r"   c                 H  ^ ^ UU 4S jnT R                   mTR                  5       [        R                  :w  a  U" S5        TR                  nTR                  (       d  U" S5        [        U5      S::  a  [        S[        U5       35      e[        S U 5       5      nU(       a  U" S5        [        [        R                  5      S[        [        R                  5      S	[        [        R                  5      S
[        [        R                  5      S[        [        R                  5      S[        [        [        R                  5      S 5      S0nTR                   HE  nUR                   U;   a  M  U" S[#        UR%                  5       5       SUR                    S35        MG     g )Nc                 @   > [        SU  STR                   ST 35      e)NzCCannot use torch._custom_ops APIs to register backward formula for z. Got operator z with schema: )r[   r`   )detailrL   rc   s    r#   error4CustomOp._check_can_register_backward.<locals>.error-  s1    %ho>>".: r"   znon-functional operatorzoperator with no returnsr   z"expected at least one return, got c              3      #    U  H4  oR                   S L=(       a    UR                   R                  (       + v   M6     g 7fr}   )
annotationis_write).0rs     r#   	<genexpr>8CustomOp._check_can_register_backward.<locals>.<genexpr>>  s/      #
LPqLL$BQ\\-B-B)BBDs   <>zoperator that returns viewsintSymIntboolfloatTensorzList[Tensor]zoperator with return not in z (got ))r\   rw   r
   
functionalreturnslenri   anyr   r   r   r   r   r   r   r   r3   listvalues)rc   r   retsis_non_mutating_viewallowed_return_typesretrL   s   `     @r#   _check_can_register_backward%CustomOp._check_can_register_backward,  sJ   	 ;;=J111+,~~~~,-t9> #Ec$i[!QRR" #
LP#
  
  /0 VZZ %V]]#XV[[!6V\\"GV]]#XXfmm,d3^ 
 >>Cxx//.t4H4O4O4Q/R.SSYZ]ZbZbYccde "r"   c                 <   U R                   (       a  g [        R                  " U R                  S5      (       a  [	        SU R                   S35      eS HE  n[        R                  " U R                  U5      (       d  M+  [	        SU R                   SU S35      e   g )NCompositeImplicitAutogradz3impl_backward/impl_save_for_backward: the operator a3   already has an implementation for this device type via a pre-existing registration to DispatchKey::CompositeImplicitAutograd.CompositeImplicitAutograd operators do not need an autograd formula; instead, the operator will decompose into its constituents and those can have autograd formulas defined on them.)r/   AutogradCPUAutogradCUDAz; already has an Autograd kernel registered to DispatchKey::z vi a pre-existing torch.library or TORCH_LIBRARY registration. Please either remove those registrations or don't use the torch._custom_ops APIs)rb   rE   %_dispatch_has_kernel_for_dispatch_keyr`   r[   )rc   r   s     r#   (_check_doesnt_have_library_autograd_impl1CustomOp._check_doesnt_have_library_autograd_implT  s    7733NN7
 
 EdnnEU V> ?  ?C77LL"$$(NN#3 4225 7YZ  ?r"   c                    U R                  S5      (       a  g [        R                  " U R                  S5      (       a'  [        R                  " U R                  S5      (       d  g [        R                  " U R                  S5      (       a  [	        SU R                   S35      e[        R                  " U R                  S5      (       a  [	        SU R                   S35      eg )Nr   CompositeExplicitAutogradr   r   z!impl_abstract(...): the operator a-   already has an implementation for this device type via a pre-existing registration to DispatchKey::CompositeImplicitAutograd.CompositeImplicitAutograd operators do not need an abstract impl; instead, the operator will decompose into its constituents and those can have abstract impls defined on them.z already has an DispatchKey::Meta implementation via a pre-existing torch.library or TORCH_LIBRARY registration. Please either remove that registration or don't call impl_abstract.)ro   rE   r   r`   r[   rj   s    r#   r   -CustomOp._check_doesnt_have_library_meta_implp  s    >>*%% 33NN7
 
::4>>6RR 33NN7
 
 3DNN3C D; <  33DNNFKK3DNN3C DV W  Lr"   c           
      ~   U R                  S5      (       d  [        S5      eU R                  S5      (       d  [        S5      e[        U R                  U R                  U [        U R                  5      U R                  S5      R                  U R                  S5      R                  5      nU R                  SU5        g )Nbackwardz&backward impl must be registered firstsave_for_backwardz/save_for_backward impl must be registered firstautograd)
ro   ri   r   r\   _output_differentiabilityget_opr`   r   rJ   rz   )rc   kernels     r#   _register_autograd_kernel"CustomOp._register_autograd_kernel  s    ~~j)) !IJJ~~122 !RSS*LL**4>>"NN./44NN:&++
 	J/r"   c                    ^ ^ UU 4S jnU$ )ziRegister a function that tells us what to save for backward.

Please see impl_backward for more details.
c                    > TR                  5         TR                  5         TR                  (       d  TR                  5         TR	                  SU TS9  TR                  S5      (       a  TR                  5         g g )Nr   r   r   )r   r   rb   rk   rz   ro   r   )r   r   rc   s    r#   rR   .CustomOp.impl_save_for_backward.<locals>.inner  sf    --/99;??::< 3Q;O~~j))..0 *r"   r!   r   s   `` r#   impl_save_for_backwardCustomOp.impl_save_for_backward  s    	1 r"   c                   ^ ^^ Tb|  U4S jn[        T[        5      (       d  U" 5         T H!  n[        U[        5      (       a  M  U" 5         M#     [        T R                  R
                  5      [        T5      :w  a  U" 5         UUU 4S jnU$ )r)   c                      > [        ST  35      e)Nzimpl_backward(output_differentiability): expected output_differentiability to be a list of bools with length equal to the number of outputs of this CustomOp got: r   )output_differentiabilitys   r#   yell$CustomOp.impl_backward.<locals>.yell  s"    " 557 r"   c                   > TR                  5         TR                  5         TR                  (       d  TR                  5         TR	                  SU TS9  TTl        TR                  S5      (       a  TR                  5         g g )Nr   r   r   )r   r   rb   rk   rz   r   ro   r   )r   r   r   rc   s    r#   rR   %CustomOp.impl_backward.<locals>.inner  sn    --/99;??::<
A+F-ED*~~122..0 3r"   )r   r   r   r   r\   r   )rc   r   r   r   diffrR   s   ```   r#   impl_backwardCustomOp.impl_backward  sq     $/ 6==0!$--F 1 4<<''(C0H,II	1 r"   )
r6   r]   ra   r^   r_   rB   r   r`   rb   r\   )r   )Nr   )r6   r?   __qualname____firstlineno__r@   rZ   rk   rz   r   ro   r   r   r   typingUnionr   IterableCallablerA   r   r   r   r   r   r   r   r   r  __static_attributes____classcell__)rf   s   @r#   r   r      s    
 PU/ /8<<!#,4 ll3(<#<= 
	.	foo !foo !F&P8%X0"   r"   c                   >    \ rS rSr% \R
                  \S'   \\S'   Srg)rv   i  rJ   rp   r!   N)	r6   r?   r  r  r  r  __annotations__r   r	  r!   r"   r#   rv   rv     s    
//Mr"   rv   rd   re   c                     UR                   c  SOUR                   n[        R                  " U  S[        UR                  5       3U5      $ )N rX   )overload_namerE   _dispatch_find_schema_or_throwr   r>   )rd   re   r  s      r#   r=   r=     sN    ))1}7R7R  ,,("S++,-. r"   rK   c                 f    SU ;   a  [        SU  S35      eU [        ;   a  [        SU  SU  S35      eg )N.zcustom_op(..., ns="zC"): expected ns to not contain any . (and be a valid variable name)zcustom_op(..., ns='z'): 'z9' is a reserved namespace, please choose something else. )r2   RESERVED_NS)rK   s    r#   r5   r5     sZ    
by!" &# $
 	
 
[!"U2$ /- .
 	
 r"   rL   c                     [         R                  R                  R                  U 5      (       d  [	        SU  35      eU R
                  R                  b  [	        SU  35      eg )Nzcustom_op only supports functional operators (ops that do not mutate any inputs, do not return views of the inputs, and has at least one return). Got the following non-functional schema: zUcustom_op does not support arguments named 'self'. Please rename your argument. Got: )r   r   utilsis_functional_schemar2   	argumentsself_arg)rL   s    r#   r8   r8     sq    >>44V<<8 9?xA
 	
   ,**03
 	
 -r"   c                     U R                  SS5      n[        U5      S:w  a  [        SU  S35      eSUS   ;   a  [        SU  35      eUS   US   4$ )	NrX   r   r   z$Expected there to be a namespace in z;, i.e. The operator name should look something like ns::foor  zThe torch.custom_ops APIs do not handle overloads, i.e. operator names with '.' in them. Please name your operator something like ns::foo. Got: r   )splitr   r2   )r%   namess     r#   r4   r4     s|    NN4#E
5zQ28* =? @
 	
 eAh :
 	
 8U1Xr"   r   c                 `    U [         ;  a$  [        SU  S[         R                  5        S35      eg )NzCustomOp.impl(device_types=[z(, ...]): we only support device_type in r  )r   r2   keys)r   s    r#   r   r     s?    66*;- 8.3356a9
 	
 7r"   paramc                     U R                   [        R                  R                  [        R                  R                  4;   $ r}   )rw   r0   	ParameterPOSITIONAL_OR_KEYWORDKEYWORD_ONLY)r  s    r#   supported_paramr#  %  s6    :://&&  r"   rJ   c                   ^ ^^^	 [         R                  " U5      m	[        S T	R                  R	                  5        5       5      (       d  [        ST	 35      e[        S T	R                  R	                  5        5       5      (       d'  T	R                  [         R                  R                  La  [        ST	 35      eT	R                  R	                  5        VVs/ s H2  u  p#UR                  [         R                  R                  :X  d  M/  X#4PM4     nnnT	R                  R	                  5        VVs/ s H2  u  p#UR                  [         R                  R                  :X  d  M/  X#4PM4     nnnU U	4S jmU U	4S jmUU4S jnU" UT R                  R                  5        U" UT R                  R                   5        g s  snnf s  snnf )Nc              3   <   #    U  H  u  p[        U5      v   M     g 7fr}   )r#  r   _ps      r#   r   3validate_function_matches_schema.<locals>.<genexpr>1  s     E.Ddaq!!.Ds   zcustom_op(..., manual_schema)(func): positional-only args, varargs, and kwargs are not supported. Please rewrite `func` to not have them. Got `func` with signature: c              3   r   #    U  H-  u  pUR                   [        R                  R                  Lv   M/     g 7fr}   )r   r0   r   emptyr&  s      r#   r   r)  9  s.      
. LL 1 1 7 77.s   57zcustom_op(..., manual_schema)(func): When passing in a manual schema, we expect `func` to have no type annotations to avoid ambiguity. Got `func` with signature: c                  &   > [        ST ST  35      e)Nzcustom_op(..., manual_schema)(func): When passing in a manual schema, we expect `func`'s signature to match `manual_schema` (aside from type annotations). func's signature: , manual_schema: r2   rL   sigs   r#   r   /validate_function_matches_schema.<locals>.errorP  )    ! "%%6vh@
 	
r"   c                  &   > [        ST ST  35      e)Nzycustom_op(..., manual_schema)(func): neither func nor manual_schema should have default arguments. Got func's signature: r-  r.  r/  s   r#   error_default_args<validate_function_matches_schema.<locals>.error_default_argsX  r2  r"   c                   > [        U 5      [        U5      :w  a  T" 5         [        X5       H[  u  u  p#nX$R                  :w  a  T" 5         UR                  [        R
                  R                  Ld  UR                  c  MT  T" 5         M]     g r}   )r   zipr>   defaultr0   r   r+  )sig_argsschema_argsr>   r  argr   r4  s        r#   compare1validate_function_matches_schema.<locals>.compare`  se    x=C,,G"%h"<MT3xx}}G$5$5$;$;;s{{?V"$	 #=r"   )r0   	signatureall
parametersitemsr2   r   return_annotation	Signaturer+  rw   r   r!  r"  r  flat_positionalflat_kwarg_only)
rL   rJ   r>   r  
positional	kwargonlyr<  r   r4  r0  s
   `      @@@r#   r9   r9   ,  s    

D
!CEcnn.B.B.DEEE<<?5B
 	
 	 
,,.
 	
 	
   (9(9(?(??558E;
 	
 >>//11KD::**@@@ 	1   >>//11KD::**777 	1  

% J((889Iv''778K
s   .F>F>2.G$Gr   r   c           
          US:X  a  [        U  S35      eUS:X  a  [        U  S35      eUS;   a'  UR                  5       n[        U  SU SU SU S	35      e[        U  S
U S35      e)N	Undefineda  : There were no Tensor inputs to this operator (e.g. you passed an empty list of Tensors). If your operator is a factory function (that is, it takes no Tensors and constructs a new one), then please use CustomOp.impl_factory to register an implementation for itr   z: when running with device='Meta' tensors: there is no abstract impl registered for this CustomOp. Please register one via CustomOp.impl_abstract to get this CustomOp to work with Meta tensors)r   r   z: when running with device='z' tensors: there is no zW impl registered for this CustomOp. Please register one via CustomOp.impl(device_type='z')z%: No implementation for dispatch key z. It is likely that we have not added this functionality yet, please either open an issue or if you're feeling adventurous, use the low-level torch.library API)NotImplementedErrorlower)r   r   devices      r#   rI   rI   m  s    
k!k ' (
 	
 f}!k T U
 	

 o!k5fX=Th **05
 	

 +:3% @ 	 r"   c           	      2   U R                   n[        R                  R                  US5      nU R	                  5       R                  S5      S   n[        U R                  5      nUR                  SSS9S   n[        R                  " U5      n[        X!XSU SS9$ )Nr,   rX   r   )maxsplitTr-   )	namespacer   r:   r;   r>   r  r   r\   rsplitr   r7   r   )oprK   rO   r>   rM   rL   s         r#   custom_op_from_existingrS    s    	B
--

J
/C779??4 $DRZZJ""4!"4R8J!!*-FCV2tDDr"   c                 6  ^  U 4S jn[        T 5      u  p#[        [        R                  U5      (       d  U" 5         [	        [        R                  U5      n[        XC5      (       d  U" 5         [	        XC5      n[        US5      (       d  U" 5         UR
                  $ )Nc                  "   > [        ST  S35      e)NzCould not find the operator z~. Please make sure you have already registered the operator and (if registered from C++) loaded it via torch.ops.load_library.r.  )r%   s   r#   error_not_foundget_op.<locals>.error_not_found  s!    *8* 54 5
 	
r"   r8  )r4   r   r   r   r   r8  )r%   rV  rK   r>   r   packets   `     r#   r   r     su    
 h'HB599b!!%))R(K;%%['F69%%>>r"   c                     U [         ;   a	  [         U    $ U(       d  [        SU  S35      e[        U 5      n[        U5      nU$ )NzCould not find custom op "z5". Did you register it via the torch._custom_ops API?)rT   r[   r   rS  )r%   also_check_torch_libraryoverloadrQ   s       r#   _find_custom_opr\    sQ    ?"x((#(
 3) *
 	
 hH$X.FMr"   c                    U [         R                  R                  R                  ;  a  g [         R                  R                  R                  U    nUc  g UR	                  S5      (       d  g UR                  S5      R                  $ )Nr   )r   
_custom_oprA   rT   ro   r   rJ   )r%   r   s     r#   get_abstract_implr_    so    u'',,<<<  %%55h?Iz**z*///r"   c           	      0   U R                  S5      u  p4U U 3n[        R                  " U5      n[        U5        U(       a%  [        R
                  R                  R                  /O/ n[        R                  " US5      nUR                  XWS9  [        X6R                  5      n	[        XXdU	SS9n
U
R                  5         [        R
                  R                  U	[         R"                  " [$        [&        R(                  " U
5      5      5        [+        U 5      $ )NrX   r,   )tagsTr-   )r  r   r7   r8   r   rE   Tagneeds_fixed_stride_orderr:   r;   r<   r=   r>   r   rk   rF   rG   rH   rI   rC   rD   r   )r%   rL   rc  rK   r>   rM   rN   ra  rO   rP   rQ   s              r#   _custom_op_with_schemard    s    ~~d#HB6&"J$**:6OO$6NEHHLL112TVD
//"j
)CJJzJ%%b*>*>?HchPTUF
002	HH00)##$97==;PQ (r"   r}   )F)T)8dataclassesrG   r0   rr   r  r   rC   r   torch._CrE   torch._library.infer_schematorch.libraryr:   r   r   torchgen.modelr   r   r   r   r	   r
   r   r   r   __all__r   r  r$   r   Optionalr  r   rT   dictr  r   	dataclassrv   r=   r5   r8   tupler4   r   r   r   r#  r9   AnyrI   rS  r   r\  r_  rd  r!   r"   r#   <module>rp     s      
      "  4 !  M
 /    :>99"(//#"69__9D *,c:o& +Y Yx
   
3 | 

3 

4 


N 
t 
"S U38_ "
c 
d 
7,,  >9>9"(//>9	>9BVZZ c d <E(
0r"   