a
    àñhÔ  ã                   @   s¨   U d Z ddlZddlZddlZG dd„ dƒZeƒ Zdd„ Zdd„ Zej 	¡ Z
i ad	d
„ Zdd„ Ze ¡ Zejed< e ¡ Zejed< dd„ Zdd„ Zdd„ Zdd„ ZdS )zÃJIT-related state

This module stores various pieces of Python-global state relating to the JIT.

This is not intended to be imported directly; please the exposed
functionalities in `torch.jit`.
é    Nc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚEnabledProxyzyStores whether the JIT is enabled or not.

    This is just a wrapper for a bool, so that we get reference semantics
    c                 C   s   |   dddd¡| _d S )NZPYTORCH_JITTz> Using PyTorch JITz> PyTorch JIT DISABLED)Ú	parse_envÚenabled©Úself© r   úP/home/yuhw/wc/uboone-dl-vtx/venv/lib/python3.9/site-packages/torch/jit/_state.pyÚ__init__   s    ÿzEnabledProxy.__init__c                 C   sr   t j |¡}|d u r|S | ¡ dv r(dS | ¡ dv r8dS |dkrLt|ƒ dS |dkr`t|ƒ dS td |¡ƒ‚d S )N>   ÚtrueÚ1ÚyesT>   ÚfalseÚnoÚ0FZ1vZ0vz(Unknown setting of {}. Try using 0 or 1.)ÚosÚenvironÚgetÚlowerÚprintÚ
ValueErrorÚformat)r   ÚnameÚdefaultZtrue_messageZfalse_messageÚvaluer   r   r   r      s    zEnabledProxy.parse_envc                 C   s   | j S ©N)r   r   r   r   r   Ú__bool__'   s    zEnabledProxy.__bool__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r   r      s   r   c                   C   s
   dt _d S )NF©Ú_enabledr   r   r   r   r   Údisable.   s    r"   c                   C   s
   dt _d S )NTr    r   r   r   r   Úenable2   s    r#   c                 C   s   | t |< d S r   ©Ú_script_classes)Úclsr   r   r   r   Ú_add_script_class?   s    r'   c                 C   s   | t vrd S t |  S r   r$   )r   r   r   r   Ú_get_script_classD   s    r(   Ú_jit_caching_layerÚ_jit_function_overload_cachingc                 C   s&   t  | d ¡}|rdd„ |D ƒS d S d S )Nc                 S   s   g | ]}t  |¡‘qS r   )Ú
_python_cuÚfind_function)Ú.0Ú	qual_namer   r   r   Ú
<listcomp>Y   ó    z1_try_get_jit_cached_overloads.<locals>.<listcomp>)r*   r   )ÚkeyZ
qual_namesr   r   r   Ú_try_get_jit_cached_overloadsV   s    r2   c                 C   s   dd„ |D ƒt | < d S )Nc                 S   s   g | ]
}|j ‘qS r   )Úqualified_name)r-   Úfnr   r   r   r/   ^   r0   z+_set_jit_overload_cache.<locals>.<listcomp>)r*   )r1   Zcompiled_fnsr   r   r   Ú_set_jit_overload_cache]   s    r5   c                 C   s6   t | ddƒdu rd S t | d ¡}|r.t |¡S d S d S )NZ __disable_jit_function_caching__FT)Úgetattrr)   r   r+   r,   )r1   r.   r   r   r   Ú_try_get_jit_cached_function`   s    
r7   c                 C   s    t |tjjƒsJ ‚|jt| < d S r   )Ú
isinstanceÚtorchZjitZScriptFunctionr3   r)   )r1   r   r   r   r   Ú_set_jit_function_cachei   s    r:   )r   r9   r   Úweakrefr   r!   r"   r#   Z_CZCompilationUnitr+   r%   r'   r(   ÚWeakKeyDictionaryr)   Ú__annotations__r*   r2   r5   r7   r:   r   r   r   r   Ú<module>   s"   
	