U
    •Ê¹jk  ã                   @   s¾   d dl mZ d dlmZmZmZ edd�G dd„ dƒƒZeeedf  eeedf  eeedf  dœd	d
„Zddddœdd„Z	eeef eeef eeef dœdd„Z
eedœdd„ZdS )é    )Ú	dataclass)ÚDictÚOptionalÚTupleT)Úfrozenc                   @   sŠ   e Zd ZU eed< eed< eed< eed< eeedf  ed< eee	ee
f d dœdd	„ƒZeed d
œdd„ƒZe	ee
f dœdd„ZdS )ÚSelectiveBuildOperatorÚnameÚis_root_operatorÚis_used_for_trainingÚinclude_all_overloads.Ú_debug_info)Úop_nameÚop_infoÚreturnc                 C   sò   dddddh}t t| ¡ ƒ| ƒdkrFtd d t| ¡ ƒ| ¡¡ƒ‚d|kr^| |d ks^t‚| dd	¡}t|t	ƒsxt‚| dd	¡}t|t	ƒs’t‚| dd	¡}t|t	ƒs¬t‚d }d|krà|d }t|t
ƒsÎt‚td
d„ |D ƒƒ}t| ||||d�S )Nr   r	   r
   r   Ú
debug_infor   z!Got unexpected top level keys: {}ú,Tc                 s   s   | ]}t |ƒV  qd S ©N)Ústr)Ú.0Úx© r   ú`/var/www/html/bwave/python/venv/lib/python3.8/site-packages/torchgen/selective_build/operator.pyÚ	<genexpr>V   s     z8SelectiveBuildOperator.from_yaml_dict.<locals>.<genexpr>©r   r	   r
   r   r   )ÚlenÚsetÚkeysÚ	ExceptionÚformatÚjoinÚAssertionErrorÚgetÚ
isinstanceÚboolÚlistÚtupler   )r   r   Zallowed_keysr	   r
   r   r   Zdi_listr   r   r   Úfrom_yaml_dict3   s@    ûÿÿûz%SelectiveBuildOperator.from_yaml_dict)r   r   c                 C   s   t | dddd d�S )NTr   )r   )r   r   r   r   Ú*from_legacy_operator_name_without_overload`   s    ûzASelectiveBuildOperator.from_legacy_operator_name_without_overload)r   c                 C   s*   | j | j| jdœ}| jd k	r&| j|d< |S )N)r	   r
   r   r   )r	   r
   r   r   )ÚselfÚretr   r   r   Úto_dictl   s    ý

zSelectiveBuildOperator.to_dictN)Ú__name__Ú
__module__Ú__qualname__r   Ú__annotations__r#   r   r   Ústaticmethodr   Úobjectr&   r'   r*   r   r   r   r   r      s   
 
þ,þr   .)ÚlhsÚrhsr   c                 C   s,   | d kr|d krd S t t| pd|p$d ƒƒS )Nr   )r%   r   ©r1   r2   r   r   r   Úmerge_debug_infox   s    r4   c                 C   sl   t | jƒt |jƒkr6tdt | jƒ› dt |jƒ› d�ƒ‚t| j| jpF|j| jpP|j| jpZ|jt| j|jƒd�S )Nz8Expected both arguments to have the same name, but got 'z' and 'z	' insteadr   )	r   r   r   r   r	   r
   r   r4   r   r3   r   r   r   Úcombine_operatorsƒ   s    ÿ


õr5   c                 C   sL   i }t |  ¡ ƒt | ¡ ƒ D ]*\}}|}||kr>t|| |ƒ}|||< q|S r   )r$   Úitemsr5   )r1   r2   Ú	operatorsr   ÚopZnew_opr   r   r   Úmerge_operator_dictsš   s     
r9   )r   r   c                 C   s   |   d¡d S )NÚ.r   )Úsplit)r   r   r   r   Ústrip_operator_overload_name©   s    r<   N)Údataclassesr   Útypingr   r   r   r   r   r4   r5   r9   r<   r   r   r   r   Ú<module>   s    	mý þ


ý