§
    Qzniº  ã                   ó¦   — U d dl mZ ddlmZ ddlZddlZddlZg d¢Z e¦   «         Z	ee
         ed<   dgZd„ Z G d	„ d
¦  «        Zd„ Zdd„Zdd„ZdS )é   )Ú
OpOverloadé    )ÚSetN)ÚLibraryÚimplÚdefineÚfallthrough_kernelÚ_implsÚprimc                  ó    — t          d¦  «        ‚)zZ
    A dummy function to pass to ``Library.impl`` in order to register a fallthrough.
    z,fallthrough_kernel() should never be called.)ÚNotImplementedError© ó    úm/var/www/html/cool-property-finder/image-detection-backend/venv/lib/python3.11/site-packages/torch/library.pyr	   r	      s   € õ ÐLÑ
MÔ
MÐMr   c                   ó0   — e Zd ZdZdd„Zd„ Zdd„Zdd„ZdS )	r   aC  
    A class to create libraries that can be used to register new operators or
    override operators in existing libraries from Python.
    A user can optionally pass in a dispatch keyname if they only want to register
    kernels corresponding to only one specific dispatch key.

    To create a library to override operators in an existing library (with name ns), set the kind to "IMPL".
    To create a new library (with name ns) to register new operators, set the kind to "DEF".
    To create a fragment of a possibly existing library to register operators (and bypass
    the limitation that there is only one library for a given namespace), set the kind to
    "FRAGMENT".

    Args:
        ns: library name
        kind: "DEF", "IMPL" (default: "IMPL"), "FRAGMENT"
        dispatch_key: PyTorch dispatch key (default: "")
    Ú c                 ó¶  — |dvrt          d|¦  «        ‚|t          v r|dk    s|dk    rt          |d¦  «        ‚t          j        d¬¦  «        d         }|j        |j        }}t          j                             |||||¦  «        | _	        || _
        t          ¦   «         | _        || _        || _        t          j        | t"          t$          | j        ¦  «         d S )	N)ÚIMPLÚDEFÚFRAGMENTzUnsupported kind: r   r   zJ is a reserved namespace. Please try creating a library with another name.é   )Úlimitr   )Ú
ValueErrorÚ_reserved_namespacesÚ	tracebackÚextract_stackÚfilenameÚlinenoÚtorchÚ_CÚ_dispatch_libraryÚmÚnsÚsetÚ	_op_implsÚkindÚdispatch_keyÚweakrefÚfinalizeÚ_del_libraryr
   )Úselfr#   r&   r'   Úframer   r   s          r   Ú__init__zLibrary.__init__*   sÔ   € ØÐ2Ð2Ð2ÝÐ1°4Ñ8Ô8Ð8àÕ%Ð%Ð%¨4°5ª=¨=¸DÀJÒ<NÐ<NÝ˜RÐ!mÑnÔnÐnåÔ'¨aÐ0Ñ0Ô0°Ô3ˆØ œ>¨5¬<�&ˆÝ”×+Ò+¨D°"°lÀHÈfÑUÔUˆŒØˆŒÝ#&¡5¤5ˆŒØˆŒ	Ø(ˆÔõ
 	Ô˜�|­V°T´^ÑDÔDÐDÐDÐDr   c                 ó8   — d| j         › d| j        › d| j        › d�S )NzLibrary(kind=z, ns=z, dispatch_key=z)>)r&   r#   r'   )r+   s    r   Ú__repr__zLibrary.__repr__>   s*   € Ø\˜tœyÐ\Ð\¨t¬wÐ\Ð\ÀtÔGXÐ\Ð\Ð\Ð\r   c                 ód   — |dvrt          d|› �¦  «        ‚| j                             ||¦  «        S )az  Defines a new operator and its semantics in the ns namespace.

        Args:
            schema: function schema to define a new operator.
            alias_analysis (optional): Indicates if the aliasing properties of the operator arguments can be
                                       inferred from the schema (default behavior) or not ("CONSERVATIVE").
        Returns:
            name of the operator as inferred from the schema.

        Example::
            >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_LIBRARY)
            >>> my_lib = Library("foo", "DEF")
            >>> my_lib.define("sum(Tensor self) -> Tensor")
        )r   ÚFROM_SCHEMAÚCONSERVATIVEzInvalid alias_analysis type )ÚRuntimeErrorr"   r   )r+   ÚschemaÚalias_analysiss      r   r   zLibrary.defineA   s=   € ð" Ð!DÐDÐDÝÐN¸nÐNÐNÑOÔOÐOØŒv�}Š}˜V ^Ñ4Ô4Ð4r   c                 óv  — t          |¦  «        st          dt          |¦  «        › �¦  «        ‚|dk    r| j        }t	          |t
          ¦  «        r|}nKt	          |t          ¦  «        r'|j        j        }|j        j	        }|dk    r|dz   |z   }nt          d¦  «        ‚| j        dz   |                     d¦  «        d         z   dz   |z   }|t          v rBt          d                     |                     d¦  «        d         || j        ¦  «        ¦  «        ‚|d	k    rE|}d|vr| j        › d|› �}t          j                             |d
¦  «        rt          d|› d�¦  «        ‚| j                             ||dk    r|nd
|¦  «         t                               |¦  «         | j                             |¦  «         dS )aê  Registers the function implementation for an operator defined in the library.

        Args:
            op_name: operator name (along with the overload) or OpOverload object.
            fn: function that's the operator implementation for the input dispatch key or :func:`~fallthrough_kernel`
                to register a fallthrough.
            dispatch_key: dispatch key that the input function should be registered for. By default, it uses
                          the dispatch key that the library was created with.

        Example::
            >>> my_lib = Library("aten", "IMPL")
            >>> def div_cpu(self, other):
            >>>     return self * (1 / other)
            >>> my_lib.impl("div.Tensor", div_cpu, "CPU")
        z;Input function is required to be a callable but found type r   ú.zQimpl should be passed either a name or an OpOverload object as the first argumentú/z::éÿÿÿÿzˆThis is not allowed since there's already a kernel registered from python overriding {}'s behavior for {} dispatch key and {} namespace.ÚMetaÚCompositeImplicitAutogradz?We should not register a meta kernel directly to the operator 'zº', because it has a CompositeImplicitAutograd kernel in core. Instead we should let the operator decompose, and ensure that we have meta kernels for the base ops that it decomposes into.N)ÚcallableÚ	TypeErrorÚtyper'   Ú
isinstanceÚstrr   Ú_schemaÚnameÚoverload_namer3   r#   Úsplitr
   Úformatr   r    Ú%_dispatch_has_kernel_for_dispatch_keyr"   r   Úaddr%   )r+   Úop_nameÚfnr'   rB   rC   ÚkeyÚdispatcher_op_names           r   r   zLibrary.implV   s   € õ  ˜‰|Œ|ð 	fÝÐdÕZ^Ð_aÑZbÔZbÐdÐdÑeÔeÐeØ˜2ÒÐØÔ,ˆLå�g�sÑ#Ô#ð 	tØˆDˆDÝ˜¥Ñ,Ô,ð 	tØ”?Ô'ˆDØ#œOÔ9ˆMØ Ò"Ð"Ø˜c‘z MÑ1�øåÐrÑsÔsÐsàŒg˜‰m˜dŸjšj¨Ñ.Ô.¨rÔ2Ñ2°SÑ8¸<ÑGˆØ•&ˆ=ˆ=õ ð  Sç%šv d§j¢j°Ñ&6Ô&6°rÔ&:¸LÈ$Ì'ÑRÔRñTô Tð Tð ˜6Ò!Ð!Ø!%ÐØÐ-Ð-Ð-Ø(,¬Ð%GÐ%GÐ3EÐ%GÐ%GÐ"õ Œx×=Ò=Ð>PÐRmÑnÔnð BÝ"ðAÐVZð Að Að AñBô Bð Bð 	Œ�Š�D¨,¸"Ò*<Ð*<˜,˜,ÐB]Ð_aÑbÔbÐbå�
Š
�3‰ŒˆØŒ×Ò˜3ÑÔÐÐÐr   N©r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r-   r/   r   r   r   r   r   r   r      sp   € € € € € ðð ð"Eð Eð Eð Eð(]ð ]ð ]ð5ð 5ð 5ð 5ð*: ð : ð : ð : ð : ð : r   r   c                 ó   — | |z  } d S ©Nr   )Úcaptured_implsÚop_implss     r   r*   r*   “   s   € Ø�hÑ€N€N€Nr   r   c                 ó   ‡ ‡‡— ˆˆ ˆfd„}|S )Nc                 ó6   •— ‰                      ‰| ‰¦  «         | S rR   )r   )Úfr'   ÚlibrB   s    €€€r   Úwrapzimpl.<locals>.wrapš   s   ø€ Ø�Š��q˜,Ñ'Ô'Ð'Øˆr   r   )rX   rB   r'   rY   s   ``` r   r   r   ™   s/   øøø€ ðð ð ð ð ð ð ð €Kr   c                 ó   ‡ ‡‡— ˆˆ ˆfd„}|S )Nc                 ó`   •— ‰                      ‰‰¦  «        }‰                     || ¦  «         | S rR   )r   r   )rW   rB   r5   rX   r4   s     €€€r   rY   zdefine.<locals>.wrap¡   s/   ø€ Ø�zŠz˜& .Ñ1Ô1ˆØ�Š��qÑÔÐØˆr   r   )rX   r4   r5   rY   s   ``` r   r   r       s/   øøø€ ðð ð ð ð ð ð ð €Kr   rL   )Ú_opsr   Útypingr   r   r   r(   Ú__all__r$   r
   r@   Ú__annotations__r   r	   r   r*   r   r   r   r   r   ú<module>r`      sÿ   ðØ Ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø €€€à
=Ð
=Ð
=€ð �3‘5”5€ˆˆCŒÐ Ð Ñ ð �xÐ ðNð Nð Nðx ð x ð x ð x ð x ñ x ô x ð x ðvð ð ðð ð ð ðð ð ð ð ð r   