
    ȅi              	           % S SK Jr  S SKJrJr  SSKJr  SSKJr  SSK	J
r
  / SQr " S S	5      r\" 5       r\\S
'    " S S5      r " S S5      rS\S\S\\S\4      4S jrg)    )Callable)AnyOptional   )EffectHolder)FakeImplHolder)RegistrationHandle)SimpleLibraryRegistrySimpleOperatorEntry	singletonc                   4    \ rS rSrSrS
S jrS\SS4S jrS	rg)r
      a"  Registry for the "simple" torch.library APIs

The "simple" torch.library APIs are a higher-level API on top of the
raw PyTorch DispatchKey registration APIs that includes:
- fake impl

Registrations for these APIs do not go into the PyTorch dispatcher's
table because they may not directly involve a DispatchKey. For example,
the fake impl is a Python function that gets invoked by FakeTensor.
Instead, we manage them here.

SimpleLibraryRegistry is a mapping from a fully qualified operator name
(including the overload) to SimpleOperatorEntry.
returnNc                     0 U l         g N_dataselfs    X/home/james-whalen/.local/lib/python3.13/site-packages/torch/_library/simple_registry.py__init__SimpleLibraryRegistry.__init__   s	    57
    qualnamer   c                 x    U R                   R                  US 5      nUc  [        U5      =U R                   U'   nU$ r   )r   getr   )r   r   ress      r   findSimpleLibraryRegistry.find   s8    jjnnXt,;)<X)FFDJJx 3
r   r   r   N)	__name__
__module____qualname____firstlineno____doc__r   strr   __static_attributes__ r   r   r
   r
      s     8S %: r   r
   r   c                   B    \ rS rSrSrS\SS4S jr\S\4S j5       r	Sr
g)	r   )   zxThis is 1:1 to an operator overload.

The fields of SimpleOperatorEntry are Holders where kernels can be
registered to.
r   r   Nc                 p    Xl         [        U5      U l        [        U5      U l        [        U5      U l        g r   )r   r   	fake_implGenericTorchDispatchRuleHoldertorch_dispatch_rulesr   effectr   r   s     r   r   SimpleOperatorEntry.__init__0   s1    %)7)A*84 	! %1$:r   c                     U R                   $ r   )r,   r   s    r   abstract_impl!SimpleOperatorEntry.abstract_impl:   s    ~~r   )r/   r,   r   r.   )r!   r"   r#   r$   r%   r&   r   propertyr   r3   r'   r(   r   r   r   r   )   s5    ; ; ; ~  r   r   c                   h    \ rS rSrS\SS4S jrS\S\S\4   S\	4S	 jr
S\S\\S\4      4S
 jrSrg)r-   ?   r   r   Nc                     0 U l         Xl        g r   r   r   r0   s     r   r   'GenericTorchDispatchRuleHolder.__init__@   s    57
%r   torch_dispatch_classfunc.c                    ^ ^ T R                  T5      (       a  [        T ST R                   35      eUT R                  T'   SU U4S jjn[	        U5      $ )Nz8 already has a `__torch_dispatch__` rule registered for c                      > T R                   T	 g r   r   r   r;   s   r   
deregister;GenericTorchDispatchRuleHolder.register.<locals>.deregisterM   s    

/0r   r    )r   RuntimeErrorr   r   r	   )r   r;   r<   r@   s   ``  r   register'GenericTorchDispatchRuleHolder.registerD   sb     99)**'((`aeanan`op  ,0

'(	1 	1 "*--r   c                 :    U R                   R                  US 5      $ r   )r   r   r?   s     r   r   #GenericTorchDispatchRuleHolder.findR   s    zz~~2D99r   r9   )r!   r"   r#   r$   r&   r   typer   r   r	   rC   r   r   r'   r(   r   r   r-   r-   ?   s\    & & &.$(.08c0B.	.: :(8CH;M2N :r   r-   opr;   r   .c                 r    [         R                  U R                  5      R                  R                  U5      $ r   )r   r   r#   r.   )rH   r;   s     r   find_torch_dispatch_rulerJ   V   s-     >>"//*??DD r   N)collections.abcr   typingr   r   effectsr   r,   r   utilsr	   __all__r
   r   __annotations__r   r-   rG   rJ   r(   r   r   <module>rQ      su    $   ! % % H 4 $9#:	  : ,: :.#'hsCx !r   