o
    ki)                     @  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  s8  h d}t t| | dkr tddt| | d|v r6| |d kr6td|  d|d  |dd	}t|t	sJtd
t
| |dd	}t|t	s^tdt
| |dd	}t|t	srtdt
| d }d|v r|d }t|tstdt
| tdd |D }t| ||||dS )N>   r   
debug_infor	   r
   r   r   z!Got unexpected top level keys: {},r   zop_name mismatch: z != r	   Tz,Expected 'is_root_operator' to be bool, got r
   z0Expected 'is_used_for_training' to be bool, got r   z1Expected 'include_all_overloads' to be bool, got r   z&Expected 'debug_info' to be list, got c                 s  s    | ]}t |V  qd S N)r   ).0x r   k/var/www/addictedbytheproject.nl/epg/venv/lib/python3.10/site-packages/torchgen/selective_build/operator.py	<genexpr>f   s    z8SelectiveBuildOperator.from_yaml_dict.<locals>.<genexpr>r   r	   r
   r   r   )lensetkeys	ExceptionformatjoinAssertionErrorget
isinstancer   typelisttupler   )r   r   allowed_keysr	   r
   r   r   di_listr   r   r   from_yaml_dict4   sT   



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_overloadp   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_dict|   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   r3   r4   r   r   r   merge_debug_info   s   r6   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   r6   r   r5   r   r   r   combine_operators   s   


r7   !dict[str, SelectiveBuildOperator]c                 C  sL   i }t |  t |  D ]\}}|}||v rt|| |}|||< q|S r   )r%   itemsr7   )r3   r4   	operatorsr   opnew_opr   r   r   merge_operator_dicts   s    
r=   r   r   c                 C  s   | j dddd S )N.   )maxsplitr   )split)r   r   r   r   strip_operator_overload_name   s   rB   N)r3   r   r4   r   r   r   )r3   r   r4   r   r   r   )r3   r8   r4   r8   r   r8   )r   r   r   r   )	
__future__r   dataclassesr   r   r6   r7   r=   rB   r   r   r   r   <module>   s    	
{

