+
    –°³jÖ#  ã                   óò   a € R t0 t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RI	H
t
Ht ]P                  ! ]4      t ! R R4      tR R ltR	 t]s] ^ k ]P&                  R
 4       t ! R R4      tRR ltR# )é    N)ÚCallable)Ú
deprecated)ÚKernelÚRegistrationHandlec                   ó„   a € ] tR t^t o RtV 3R lR lt]R 4       t]P                  R 4       tRR/V 3R lR	 llt	R
t
V tR# )ÚFakeImplHolderz/A holder where one can register a fake impl to.c                ó    <€ V ^8„  d   QhRS[ /# )é   Úqualname)Ústr)ÚformatÚ__classdict__s   "€ÚY/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/_library/fake_impl.pyÚ__annotate__ÚFakeImplHolder.__annotate__   s   ø€ ÷ (ñ (¡ñ (ó    c                ó    € Wn         . V n        R # ©N)r   Úkernels)Úselfr   s   &&r   Ú__init__ÚFakeImplHolder.__init__   s   € Ø%Œð &(ˆŽr   c                ó`   € \        V P                  4      ^ 8X  d   R# V P                  R,          # )r   Néÿÿÿÿ)Úlenr   )r   s   &r   ÚkernelÚFakeImplHolder.kernel   s%   € äˆt�|‰|Ó Ô!ÙØ�|‰|˜BÕÐr   c                ó   € \        R 4      h)zUnable to directly set kernel.©ÚRuntimeError)r   Úvalues   &&r   r   r   "   s   € äÐ;Ó<Ð<r   Úallow_overrideTc                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r
   ÚfuncÚsourceÚreturn)r   r   r   )r   r   s   "€r   r   r   &   s%   ø€ ÷ ;ñ ;Ùð;Ù&)ð;á	ñ;r   c               ó,  a a€ V'       gÑ   S P                   e1   \        RS P                   RS P                   P                   R24      h\        P
                  P                  S P                  R4      '       d   \        RS P                   R24      h\        P
                  P                  S P                  R4      '       d   \        RS P                   R24      h\        W4      oS P                  P                  S4       VV 3R lp\        S P                  S 4      p VP                  S P                  VRVR	7       \!        T4      pT#   \         d>    \        P                  R
S P                  4       S P                  P                  S4       h i ; i)zdRegister a fake impl.

Returns a RegistrationHandle that one can use to de-register this
fake impl.
z!register_fake(...): the operator z' already has a fake impl registered at Ú.ÚMetaz³ already has a DispatchKey::Meta implementation via a pre-existing torch.library or TORCH_LIBRARY registration. Please either remove that registration or don't call register_fake.ÚCompositeImplicitAutograda$   already has an implementation for this device type via a pre-existing registration to DispatchKey::CompositeImplicitAutograd.CompositeImplicitAutograd operators do not need a fake impl; instead, the operator will decompose into its constituents and those can have fake impls defined on them.c                  ó>   <€ SP                   P                  S 4       R # r   )r   Úremove)r   r   s   €€r   Úderegister_fake_kernelÚ7FakeImplHolder.register.<locals>.deregister_fake_kernelR   s   ø€ Ø�L‰L×Ñ Ö'r   )r"   z"Failed to register fake_impl '%s':)r   r    r   r%   ÚtorchÚ_CÚ%_dispatch_has_kernel_for_dispatch_keyr   r   ÚappendÚconstruct_meta_kernelÚimplÚ	ExceptionÚlogÚinfor,   r   )	r   r$   r%   Úlibr"   r-   Úmeta_kernelÚhandler   s	   f&&&$   @r   ÚregisterÚFakeImplHolder.register&   sq  ù€ ÷ Ø�{‰{Ò&Ü"Ø7¸¿¹°ð G=à—{‘{×)Ñ)Ð*¨!ð-óð ô
 �x‰x×=Ñ=¸d¿m¹mÈV×TÒTÜ"Ø7¸¿¹°ð G%ð &óð ô �x‰x×=Ñ=Ø—‘Ð:÷ò ô #Ø7¸¿¹°ð G;ð <ó
ð 
ô ˜Ó%ˆØ�‰×Ñ˜FÔ#ö	(ô ,¨D¯M©M¸4Ó@ˆð	Ø�H‰H�T—]‘] K°ÈˆHÔWô $Ð$:Ó;ˆØˆøô ô 	Ü�H‰HØ4Ø—‘ôð �L‰L×Ñ Ô'Øð	ús   ÄE ÅAF)r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úpropertyr   Úsetterr;   Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      sU   ø‡ € Ù9÷(ð (ð ñ ó ð ð
 ‡]�]ñ=ó ð=ð;ØBF÷;÷ ;ð ;r   r   c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r
   r   Úfake_impl_holderr&   )r   r   r   )r   s   "r   r   r   d   s!   € ÷ ñ ¤Cð ¼>ð Ìhñ r   c                 ó¤   a a€ SP                   f   \        R4      h\        P                  ! SP                   P                  4      VV 3R l4       pV# )Nú(fake_impl_holder.kernel must not be Nonec                  óú   <a€ SP                   f   \        R4      hSP                   P                  oVV3R lp\        V4      ;_uu_ 4        SP                   ! V / VB uuR R R 4       #   + '       g   i     R # ; i)NrJ   c                  ó&   <€ \        S  R S R24      h)z (a¿  ): You're trying to run this operator with meta Tensors (as opposed to FakeTensors), but this operator may return an output Tensor with data-dependent shape. Meta Tensors don't support operators with outputs that have data-dependent shapes but FakeTensors do. If your operator does not return an output with data-dependent shape, make sure the FakeTensor and/or meta kernel does not call torch.library.get_ctx(). Otherwise, please use FakeTensors.r   )r   r%   s   €€r   Úerror_on_ctxÚ@construct_meta_kernel.<locals>.meta_kernel.<locals>.error_on_ctxn   s'   ø€ ÜØ�*˜B˜v˜hð 'Nð Oó	ð 	r   )r   ÚAssertionErrorr%   Úset_ctx_getter)ÚargsÚkwargsrM   r%   rH   r   s   *, @€€r   r9   Ú*construct_meta_kernel.<locals>.meta_kernelh   s`   ù€ à×"Ñ"Ò*Ü Ð!KÓLÐLØ!×(Ñ(×/Ñ/ˆö
	ô ˜L×)Õ)Ø#×*Ò*¨DÐ;°FÑ;÷ *×)×)Ó)ús   ÁA)Á)A:	)r   rO   Ú	functoolsÚwrapsr$   )r   rH   r9   s   ff r   r3   r3   d   sK   ù€ Ø×ÑÒ&ÜÐGÓHÐHä‡_‚_Ð%×,Ñ,×1Ñ1Ó2õ<ó 3ð<ð( Ðr   c                  ó   € R # r   © rW   r   r   Úget_nonerX   €   s   € Ùr   c              #   ó:   "  € \         p V s R x € Vs R #   Ts i ; i5ir   )Úglobal_ctx_getter)Ú
ctx_getterÚprevs   & r   rP   rP   ‡   s&   é € ô €Dð!Ø&ÐÛà Òø˜DÑüs   ‚Š �”˜c                   ó€   a € ] tR t^’t o RtR t]! R]R7      R^RR/V 3R lR	 ll4       tR^ RR/V 3R
 lR llt	Rt
V tR# )ÚFakeImplCtxzG
Context object for writing fake implementations for custom operators.
c                ó@   € Wn         VP                  V n        W n        R # r   )Ú
_fake_modeÚ	shape_envÚ
_shape_envÚ_op)r   r`   rc   s   &&&r   r   ÚFakeImplCtx.__init__—   s   € Ø$ŒØ$×.Ñ.ˆŒØŽr   zM`create_unbacked_symint` is deprecated, please use `new_dynamic_size` instead)ÚcategoryÚminÚmaxNc                ó4   <€ V ^8„  d   QhRS[ P                  /# ©r
   r&   ©r/   ÚSymInt)r   r   s   "€r   r   ÚFakeImplCtx.__annotate__    s   ø€ ÷ 7ñ 7¹E¿L¹Lñ 7r   c               ó&   € V P                  WR 7      # ©)rf   rg   )Únew_dynamic_size©r   rf   rg   s   &$$r   Úcreate_unbacked_symintÚ"FakeImplCtx.create_unbacked_symintœ   s   € ð
 ×$Ñ$¨Ð$Ó6Ð6r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# ri   rj   )r   r   s   "€r   r   rl   £   s   ø€ ÷ F8ñ F8±e·l±lñ F8r   c               ó¸  € V P                   e   V P                   P                  '       g4   \        P                  P                  P                  V P                  4      h\        V\        P                  4      '       g!   \        V\        P                  4      '       d   \        RV RV R24      hV^ 8  d   \        RV R24      h\        V P                   W4      # )aÍ  Constructs a new symint (symbolic int) representing a data-dependent value.

This is useful for writing the fake implementation (which is necessary
for torch.compile) for a CustomOp where an output Tensor has a size
that depends on the data of the input Tensors.

Args:
    min (int): A statically known inclusive lower bound for this symint. Default: 0
    max (Optional[int]): A statically known inclusive upper bound for this
        symint. Default: None

.. warning:

    It is important that the ``min`` and ``max`` (if not None) values are set
    correctly, otherwise, there will be undefined behavior under
    torch.compile. The default value of ``min`` is 2 due to torch.compile
    specializing on 0/1 sizes.

    You must also verify that your implementation on concrete Tensors
    (e.g. CPU/CUDA) only returns Tensors where the size that corresponds
    to the symint also has respects these constraint.
    The easiest way to do this is to add an assertion in the CPU/CUDA/etc
    implementation that the size follows these bounds.

Example::

    >>> # An operator with data-dependent output shape
    >>> lib = torch.library.Library("mymodule", "FRAGMENT")
    >>> lib.define("mymodule::custom_nonzero(Tensor x) -> Tensor")
    >>>
    >>> @torch.library.register_fake("mymodule::custom_nonzero")
    >>> def _(x):
    >>>     # Number of nonzero-elements is data-dependent.
    >>>     # Since we cannot peek at the data in a fake impl,
    >>>     # we use the ctx object to construct a new symint that
    >>>     # represents the data-dependent size.
    >>>     ctx = torch.library.get_ctx()
    >>>     nnz = ctx.new_dynamic_size()
    >>>     shape = [nnz, x.dim()]
    >>>     result = x.new_empty(shape, dtype=torch.int64)
    >>>     return result
    >>>
    >>> @torch.library.impl(lib, "custom_nonzero", "CPU")
    >>> def _(x):
    >>>     x_np = x.numpy()
    >>>     res = np.stack(np.nonzero(x_np), axis=1)
    >>>     return torch.tensor(res, device=x.device)

zctx.new_dynamic_size(min=z, max=zZ): expected min and max to be statically known ints but got SymInt. This is not supported.zc, ...): expected min to be greater than or equal to 0: this API can only create non-negative sizes.)rb   Úallow_dynamic_output_shape_opsr/   Ú_subclassesÚfake_tensorÚDynamicOutputShapeExceptionrc   Ú
isinstancerk   Ú
ValueErrorÚallocate_sizerp   s   &$$r   ro   ÚFakeImplCtx.new_dynamic_size£   s¿   € ðf �O‰OÒ#Ø—?‘?×A×AÐAä×#Ñ#×/Ñ/×KÑKÈDÏHÉHÓUÐUä�cœ5Ÿ<™<×(Ò(¬J°s¼E¿L¹L×,IÒ,IÜØ+¨C¨5°°s°eð <)ð *óð ð �Œ7ÜØ+¨C¨5ð 1&ð 'óð ô ˜TŸ_™_¨cÓ7Ð7r   )r`   rc   rb   )r=   r>   r?   r@   rA   r   r   ÚFutureWarningrq   ro   rD   rE   rF   s   @r   r^   r^   ’   sc   ø‡ € ñòñ
 ØWØôð7¨Að 7°4÷ 7ñ 7ó	ð7ðF8 að F8¨T÷ F8÷ F8ð F8r   r^   c                 ó�   € V P                  4       p\        P                  P                  P                  P                  W1VR 7       V# rn   )rq   r/   ÚfxÚexperimentalÚsymbolic_shapesÚ_constrain_range_for_size)ra   Úmin_valÚmax_valÚresults   &&& r   r{   r{   ì   s@   € Ø×-Ñ-Ó/€FÜ	‡H�H×Ñ×)Ñ)×CÑCØ ð Dô ð €Mr   c                ó@   € V ^8„  d   Qh/ ^ \         9   d
   \        ;R&   # )r
   rZ   )Ú__conditional_annotations__r   )r   s   "r   r   r      s   € × Ñ ÷D 'Ò &”8Ñ &òE r   )r   N)r‡   Ú
contextlibrT   ÚloggingÚcollections.abcr   Útyping_extensionsr   r/   Útorch._library.utilsr   r   Ú	getLoggerr=   r6   r   r3   rX   rZ   ÚcontextmanagerrP   r^   r{   r   )r‡   s   @r   Ú<module>r�      s~   øðç Ð Û Û Ý $Ý (ã ß ;ð ×Ò˜Ó!€÷Rñ Rõjò8ð 'Ð Ó &ð ×Ññ!ó ð!÷W8ñ W8ötr   