
    sh                        % S SK r S SKJr  S SKJr  S SKrS SKJrJrJ	r	  S r
S rSrSr " S S	5      rSS
 jr\SS j5       r " S S\	5      r\(       a  \\S'   \\S'   \\S'   \" \ R&                  \   \5      \ R&                  \'   g)    N)contextmanager)TYPE_CHECKING)__allow_nonbracketed_mutationContextProp
PropModulec                  6    [         R                  R                  $ )z5Return whether PyTorch is built with MKL-DNN support.)torch_C_has_mkldnn     r/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/torch/backends/mkldnn/__init__.pyis_availabler   
   s    88r         c                   *    \ rS rSrSrS rS rS rSrg)verbose   av  
On-demand oneDNN (former MKL-DNN) verbosing functionality.

To make it easier to debug performance issues, oneDNN can dump verbose
messages containing information like kernel size, input data size and
execution duration while executing the kernel. The verbosing functionality
can be invoked via an environment variable named `DNNL_VERBOSE`. However,
this methodology dumps messages in all steps. Those are a large amount of
verbose messages. Moreover, for investigating the performance issues,
generally taking verbose messages for one single iteration is enough.
This on-demand verbosing functionality makes it possible to control scope
for verbose message dumping. In the following example, verbose messages
will be dumped out for the second inference only.

.. highlight:: python
.. code-block:: python

    import torch
    model(data)
    with torch.backends.mkldnn.verbose(torch.backends.mkldnn.VERBOSE_ON):
        model(data)

Args:
    level: Verbose level
        - ``VERBOSE_OFF``: Disable verbosing
        - ``VERBOSE_ON``:  Enable verbosing
        - ``VERBOSE_ON_CREATION``: Enable verbosing, including oneDNN kernel creation
c                     Xl         g Nlevel)selfr   s     r   __init__verbose.__init__2   s    
r   c                     U R                   [        :X  a  g [        R                  R                  R                  U R                   5      nU(       d   S5       eU $ )NzVFailed to set MKLDNN into verbose mode. Please consider to disable this verbose scope.)r   VERBOSE_OFFr	   r
   _verbosemkldnn_set_verbose)r   sts     r   	__enter__verbose.__enter__5   sI    ::$XX11$**=	dc	dr   c                 ^    [         R                  R                  R                  [        5        g)NF)r	   r
   r   r   r   )r   exc_typeexc_valexc_tbs       r   __exit__verbose.__exit__>   s    ,,[9r   r   N)	__name__
__module____qualname____firstlineno____doc__r   r!   r'   __static_attributes__r   r   r   r   r      s    :r   r   c                    [         R                  R                  5       [         R                  R                  5       [         R                  R	                  5       4nU b  [         R                  R                  U 5        Ub  [         R                  R                  U5        Ub  [         R                  R                  U5        U$ r   )r	   r
   _get_mkldnn_enabled_get_mkldnn_deterministic_get_onednn_allow_tf32_set_mkldnn_enabled_set_mkldnn_deterministic_set_onednn_allow_tf32)_enabled_deterministic_allow_tf32
orig_flagss       r   	set_flagsr:   C   s    $$&**,'')J
 $$X.!**>:''4r   c              #   0  #    [        5          [        XU5      nS S S 5         S v   [        5          [        W6   S S S 5        g ! , (       d  f       N/= f! , (       d  f       g = f! [        5          [        W6   S S S 5        f ! , (       d  f       f = f= f7fr   )r   r:   )enableddeterministic
allow_tf32r9   s       r   flagsr?   R   se     	&	(wzB
 
)#*,z" -, 
)	(
 -,*,z" -,,s_   BABA% 
B	A	B
AB
A"B%B0	B9	B
BBBc                   N  ^  \ rS rSrU 4S jr\" \R                  R                  \R                  R                  5      r
\" \R                  R                  \R                  R                  5      r\" \R                  R                  \R                  R                  5      rSrU =r$ )MkldnnModule]   c                 $   > [         TU ]  X5        g r   )superr   )r   mname	__class__s      r   r   MkldnnModule.__init__^   s    !r   r   )r)   r*   r+   r,   r   r   r	   r
   r0   r3   r<   r1   r4   r=   r2   r5   r>   r.   __classcell__)rG   s   @r   rA   rA   ]   sr    " %((668T8TUG**EHH,N,NM '')H)HJr   rA   r<   r=   r>   )NNN)FFT)sys
contextlibr   typingr   r	   torch.backendsr   r   r   r   r   
VERBOSE_ONVERBOSE_ON_CREATIONr   r:   r?   rA   __annotations__modulesr)   r   r   r   <module>rR      s    
 %    Q Q 
 
 , ,^ # #
: 
 $S[[%:HEH r   