
    4g0j                         d dl mZ d dlmZmZmZmZmZmZm	Z	m
Z
mZmZmZ  G d d          Z G d d          Z G d d          Z G d	 d
          ZdS )    )Any)
AnnotationArgument	ArgumentsBaseOperatorNameBaseTyBaseTypeCustomClassTypeFunctionSchemaListTypeOperatorNameReturnc                   v    e Zd Zeej        eej        eej        eej        iZe	de
deez  ez  fd            ZdS )TypeGenobjreturnc                    dd l }t          | |j        j                  rt	          t
          j                  S t          | |j                  rt	          t
          j                  S t          | |j                  rt	          t
          j                  S t          | |j                  rt	          t
          j                  S t          | |j	                  r3t          |                                                                           S t          | t          t          f          rt          |           dk    rt!          d          d | D             }t          t#          |                    dk    rt%          d| d          t'          |d         t          |                     S t)          |           }|t*          j        vrt%          d|           t	          t*          j        |                   S )Nr   zlist/tuple must be non-emptyc                 B    g | ]}t                               |          S  )r   from_example).0xs     \/home/wildlama/miniconda3/envs/lam/lib/python3.11/site-packages/torchgen/gen_schema_utils.py
<listcomp>z(TypeGen.from_example.<locals>.<listcomp>0   s&    AAAG0033AAA       zFCannot generate schema for a sequence of args of heterogeneous types: zc. Consider unpacking the argument and give proper names to them if possible instead of using *args.zunsupported type )torch
isinstancefxGraphModuler	   r   TensorSymIntSymBoolScriptObjectr
   _typenamelisttuplelenAssertionErrorsetRuntimeErrorr   typer   convert_to_base_ty)r   r   all_base_tystps       r   r   zTypeGen.from_example   s   c58/00 	7F.///U\** 	7FM***U\** 	7FM***U]++ 	7FN+++U/00 	7"399;;#3#3#5#5666dE]++ 
	73xx1}}$%CDDDAASAAAL3|$$%%))".]i . . .  
 LOSXX666#YYW///7277888226777r   N)__name__
__module____qualname__intr   floatstrboolr.   staticmethodr   r	   r   r
   r   r   r   r   r   r      sp        VZv|VZfk	 8# 8(X"5"G 8 8 8 \8 8 8r   r   c            	       B    e Zd Zededz  dededz  defd            ZdS )	ReturnGenr&   Nr   
annotationr   c                 T    t          | t                              |          |          S N)r   r   r   )r&   r   r;   s      r   r   zReturnGen.from_example?   s$     dG0055zBBBr   )	r1   r2   r3   r8   r6   r   r   r   r   r   r   r   r:   r:   >   se        CDjC"C0:T0AC	C C C \C C Cr   r:   c                   F    e Zd Zededededz  dedz  def
d            ZdS )ArgumentGenr&   r   defaultNr;   r   c                 X    t          | t                              |          ||          S )N)r@   r;   )r   r   r   )r&   r   r@   r;   s       r   r   zArgumentGen.from_exampleG   s2     '&&s++W
 
 
 	
r   )	r1   r2   r3   r8   r6   r   r   r   r   r   r   r   r?   r?   F   sc        


&)Dj
>H4>O
	
 
 
 \
 
 
r   r?   c            	       f    e Zd Zededeeeef         df         deedf         defd            ZdS )FunctionSchemaGenop_nameexample_inputs.example_outputsr   c           
         g }|D ]5\  }}|                     t                              ||d d                      6t          t	                      d t	          |          t	                      d t	                      t	                                }t	          d |D                       }t          t          | ddd          d          } t          | ||          S )Nc              3   N   K   | ] }t                               d |d           V  !d S r=   )r:   r   )r   outs     r   	<genexpr>z1FunctionSchemaGen.from_example.<locals>.<genexpr>^   sE       
 
8;I""4d33
 
 
 
 
 
r   F )appendr?   r   r   r(   r   r   r   )rD   rE   rF   argsr&   inp	argumentsreturnss           r   r   zFunctionSchemaGen.from_exampleQ   s     ' 	I 	IID#KK00sD$GGHHHHGGT5;;uww
 
	  
 
?N
 
 
 
 
 /uMMrRRgy':::r   N)	r1   r2   r3   r8   r6   r(   r   r   r   r   r   r   rC   rC   P   sp        ;;eCHos23; sCx; 
	; ; ; \; ; ;r   rC   N)typingr   torchgen.modelr   r   r   r   r   r	   r
   r   r   r   r   r   r:   r?   rC   r   r   r   <module>rS      sL                                 ($8 $8 $8 $8 $8 $8 $8 $8NC C C C C C C C
 
 
 
 
 
 
 
; ; ; ; ; ; ; ; ; ;r   