o
    vZhm                     @  s\   d dl mZ d dlmZ eddG dd dZdddZdddZdddZdddZdS )    )annotations)	dataclassT)frozenc                   @  s\   e Zd ZU ded< ded< ded< ded< ded< edddZedddZdddZdS )SelectiveBuildOperatorstrnameboolis_root_operatoris_used_for_traininginclude_all_overloadstuple[str, ...] | None_debug_infoop_nameop_infodict[str, object]returnc                 C  s   h d}t t| | dkr tddt| | d|v r,| |d ks,J |dd}t|ts9J |dd}t|tsFJ |d	d}t|tsSJ d }d
|v rm|d
 }t|t	sdJ t
dd |D }t| ||||dS )N>   r   r   
debug_infor
   r	   r   z!Got unexpected top level keys: {},r   r	   Tr
   r   r   c                 s  s    | ]}t |V  qd S N)r   ).0x r   P/var/www/auris/lib/python3.10/site-packages/torchgen/selective_build/operator.py	<genexpr>W   s    z8SelectiveBuildOperator.from_yaml_dict.<locals>.<genexpr>r   r	   r
   r   r   )lensetkeys	Exceptionformatjoinget
isinstancer   listtupler   )r   r   Zallowed_keysr	   r
   r   r   Zdi_listr   r   r   from_yaml_dict4   s6   z%SelectiveBuildOperator.from_yaml_dictc                 C  s   t | dddd dS )NTr   )r   )r   r   r   r   *from_legacy_operator_name_without_overloada   s   zASelectiveBuildOperator.from_legacy_operator_name_without_overloadc                 C  s*   | j | j| jd}| jd ur| j|d< |S )N)r	   r
   r   r   )r	   r
   r   r   )selfretr   r   r   to_dictm   s   

zSelectiveBuildOperator.to_dictN)r   r   r   r   r   r   )r   r   r   r   )r   r   )__name__
__module____qualname____annotations__staticmethodr%   r&   r)   r   r   r   r   r      s   
 ,r   lhsr   rhsr   c                 C  s,   | d u r
|d u r
d S t t| pd|pd S )Nr   )r$   r   r/   r0   r   r   r   merge_debug_infoy   s   r2   c                 C  sl   t | jt |jkrtdt | j dt |j dt| j| jp#|j| jp(|j| jp-|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   r2   r   r1   r   r   r   combine_operators   s   


r3   !dict[str, SelectiveBuildOperator]c                 C  sL   i }t |  t |  D ]\}}|}||v rt|| |}|||< q|S r   )r#   itemsr3   )r/   r0   	operatorsr   opZnew_opr   r   r   merge_operator_dicts   s    
r8   r   r   c                 C  s   |  dd S )N.r   )split)r   r   r   r   strip_operator_overload_name   s   r;   N)r/   r   r0   r   r   r   )r/   r   r0   r   r   r   )r/   r4   r0   r4   r   r4   )r   r   r   r   )	
__future__r   dataclassesr   r   r2   r3   r8   r;   r   r   r   r   <module>   s    	
l

