U
    9%e                     @   s   d Z ddlZddlmZmZmZ ddlZddlmZ	m
Z
 ddlZddlmZmZmZmZmZ eddd Zd	d
ddddhZeejef eeje	f dddZdS )a  
This is a simple interpreter for Sympy expressions that dispatches to
classes following the torch._inductor.virtualized calling convention.
For directness, the interpreter takes the handler directly rather than
consulting the TLS.  It does not use most of the methods on the full
handler; only those with corresponding Sympy expressions.  To see an example
of a full handler, see torch.utils._sympy.value_ranges.ValueRangeAnalysis.
    N)AnyDictUnion)BooleanBooleanAtom   )CleanDivFloorDivModModularIndexingWherec               6   C   s   ddl m} m} tjdtjdtjdtjdtjdtj	dtj
d	tjd
tjd|dtdtdtdtjdtjd| dtjdtdtjdtjdtjdtjdtjdtjdtjdtjdtdi}|S )Nr   )PowTrueDivor_and_eqneltgtlegenot_truedivfloordivdivwhereaddmulpowmodabslogexpfloorceilminimummaximumZmodular_indexing)Z%torch.fx.experimental.symbolic_shapesr   r   sympyOrAndEqZNeLtGtZLeZGeNotr	   r   r   AddZMulr
   ZAbsr!   r"   r#   ZceilingZMinZMaxr   )r   r   ZHANDLERS r/   X/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/torch/utils/_sympy/interp.pyhandlers   sr                               r1   r%   r&   r   r   r   r   )envexprc           	         s*  d }t |trtj}n&t |tjr*tj}nt |tjr<tj}|d k	rP 	||S t |tj
rd| S t |tjrt |jd tjjjr t |jd S  fdd|jD }t |j }t |}|tkrt|dkst||d |d }tdt|D ]}|||| }q|S || S d S )Nr   r   c                    s   g | ]}t  |qS r/   )sympy_interp).0arganalysisr2   r/   r0   
<listcomp>[   s     z sympy_interp.<locals>.<listcomp>   )
isinstancer   torchboolr'   IntegerZint64NumberdoubleZconstantSymbolr   argscorenumbersZHalfsqrtr4   r1   funcgetattrASSOCIATIVE_OPSlenAssertionErrorrange)	r8   r2   r3   ZdtyperB   handler_namehandleraccir/   r7   r0   r4   C   s4    
 

r4   )__doc__	functoolstypingr   r   r   r'   Zsympy.logic.boolalgr   ZSympyBooleanr   r<   Z	functionsr   r	   r
   r   r   	lru_cacher1   rH   rA   Exprr4   r/   r/   r/   r0   <module>   s   	
( 