U
    Kºcm  ã                   @   s¦   U d dl Z d dlZd dlZd dlmZ eedœdd„Zeedœdd„ZG dd	„ d	e	ƒZ
G d
d„ de	ƒZG dd„ dejƒZee je eƒe je< eed< ee ed< dS )é    N)ÚList)ÚqengineÚreturnc                 C   sl   | dks| dks| d krd}nJ| dkr,d}n<| dkr:d}n.| dkrHd	}n | d
krVd}nd}t d | ¡ƒ‚|S )NÚnoneÚ r   Úfbgemmé   Úqnnpacké   Úonednné   Úx86é   éÿÿÿÿz,{} is not a valid value for quantized engine)ÚRuntimeErrorÚformat)r   Úret© r   úE/tmp/pip-unpacked-wheel-gikjz4vx/torch/backends/quantized/__init__.pyÚ_get_qengine_id   s    r   c                 C   s   ddddddœ}|  | d¡S )Nr   r   r	   r   r   )r   r   r
   r   r   z
*undefined)Úget)r   Zall_enginesr   r   r   Ú_get_qengine_str   s    r   c                   @   s*   e Zd Zedœdd„Zeddœdd„ZdS )Ú_QEngineProp©r   c                 C   s   t tj ¡ ƒS ©N)r   ÚtorchÚ_CZ_get_qengine)ÚselfÚobjÚobjtyper   r   r   Ú__get__   s    z_QEngineProp.__get__N)Úvalr   c                 C   s   t j t|ƒ¡ d S r   )r   r   Z_set_qenginer   ©r   r   r!   r   r   r   Ú__set__    s    z_QEngineProp.__set__)Ú__name__Ú
__module__Ú__qualname__Ústrr    r#   r   r   r   r   r      s   r   c                   @   s,   e Zd Zee dœdd„Zddœdd„ZdS )Ú_SupportedQEnginesPropr   c                 C   s   t j ¡ }dd„ |D ƒS )Nc                 S   s   g | ]}t |ƒ‘qS r   )r   )Ú.0Zqer   r   r   Ú
<listcomp>&   s     z2_SupportedQEnginesProp.__get__.<locals>.<listcomp>)r   r   Z_supported_qengines)r   r   r   Zqenginesr   r   r   r    $   s    
z_SupportedQEnginesProp.__get__Nc                 C   s   t dƒ‚d S )NzAssignment not supported)r   r"   r   r   r   r#   (   s    z_SupportedQEnginesProp.__set__)r$   r%   r&   r   r'   r    r#   r   r   r   r   r(   #   s   r(   c                       s0   e Zd Z‡ fdd„Zdd„ Zeƒ Zeƒ Z‡  Z	S )ÚQuantizedEnginec                    s   t t| ƒ |¡ || _d S r   )Úsuperr+   Ú__init__Úm)r   r.   Úname©Ú	__class__r   r   r-   ,   s    zQuantizedEngine.__init__c                 C   s   | j  |¡S r   )r.   Ú__getattribute__)r   Úattrr   r   r   Ú__getattr__0   s    zQuantizedEngine.__getattr__)
r$   r%   r&   r-   r4   r   Úenginer(   Úsupported_enginesÚ__classcell__r   r   r0   r   r+   +   s   r+   r5   r6   )Úsysr   ÚtypesÚtypingr   r'   Úintr   r   Úobjectr   r(   Ú
ModuleTyper+   Úmodulesr$   Ú__annotations__r   r   r   r   Ú<module>   s    