
    a,ju                         U d dl mZ d dlmZ ddlmZ ddlmZ ddlm	Z	 g dZ
 G d d	          Z e            Zeed
<    G d d          Z G d d          Zdedededef         dz  fdZdS )    )Callable)Any   )EffectHolder)FakeImplHolder)RegistrationHandle)SimpleLibraryRegistrySimpleOperatorEntry	singletonc                   *    e Zd ZdZddZdeddfdZdS )	r	   aJ  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                     i | _         d S N_dataselfs    ^/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/torch/_library/simple_registry.py__init__zSimpleLibraryRegistry.__init__   s    57


    qualnamer
   c                 r    | j                             |d           }|t          |          x| j         |<   }|S r   )r   getr
   )r   r   ress      r   findzSimpleLibraryRegistry.find   s:    jnnXt,,;)<X)F)FFDJx 3
r   r   N)__name__
__module____qualname____doc__r   strr    r   r   r	   r	      sU         8 8 8 8S %:      r   r	   r   c                   >    e Zd ZdZdeddfdZedefd            ZdS )r
   zThis is 1:1 to an operator overload.

    The fields of SimpleOperatorEntry are Holders where kernels can be
    registered to.
    r   r   Nc                     || _         t          |          | _        t          |          | _        t          |          | _        d S r   )r   r   	fake_implGenericTorchDispatchRuleHoldertorch_dispatch_rulesr   effectr   r   s     r   r   zSimpleOperatorEntry.__init__0   s@    %)7)A)A*844 	! %1$:$:r   c                     | j         S r   )r%   r   s    r   abstract_implz!SimpleOperatorEntry.abstract_impl:   s
    ~r   )	r   r   r   r    r!   r   propertyr   r+   r"   r   r   r
   r
   )   sg         ; ; ; ; ; ; ~    X  r   r
   c                   h    e Zd ZdeddfdZdededef         defdZ	dededef         dz  fd	Z
dS )
r&   r   r   Nc                 "    i | _         || _        d S r   )r   r   r)   s     r   r   z'GenericTorchDispatchRuleHolder.__init__@   s    57
%r   torch_dispatch_classfunc.c                                                      rt           d j                   | j        <   d fd}t	          |          S )Nz8 already has a `__torch_dispatch__` rule registered for r   c                       j         = d S r   r   r   r/   s   r   
deregisterz;GenericTorchDispatchRuleHolder.register.<locals>.deregisterM   s    
/000r   r   )r   RuntimeErrorr   r   r   )r   r/   r0   r4   s   ``  r   registerz'GenericTorchDispatchRuleHolder.registerD   s     99)** 	'ppaeanpp   ,0
'(	1 	1 	1 	1 	1 	1 	1 "*---r   c                 8    | j                             |d           S r   )r   r   r3   s     r   r   z#GenericTorchDispatchRuleHolder.findR   s    z~~2D999r   )r   r   r   r!   r   typer   r   r   r6   r   r"   r   r   r&   r&   ?   s        & & & & & &.$(.08c0B.	. . . .: :(382Dt2K : : : : : :r   r&   opr/   r   .Nc                 p    t                               | j                  j                            |          S r   )r   r   r   r'   )r9   r/   s     r   find_torch_dispatch_ruler;   V   s0     >>"/**?DD  r   )collections.abcr   typingr   effectsr   r%   r   utilsr   __all__r	   r   __annotations__r
   r&   r8   r;   r"   r   r   <module>rB      sH   $ $ $ $ $ $ $       ! ! ! ! ! ! % % % % % % % % % % % % H
G
G       4 $9#8#:#:	  : : :       ,: : : : : : : :.#'c3h$     r   