
    uki&                       d dl mZ d dlmZ d dlmZ ddl ddlmZ ddlm	Z	m
Z
mZ ddlmZmZmZ ed	d
dyd       ZdzdZ ed      d        Z ed      d        Z ed      d        Z ed      d        Z ed      d        Z ed      d        Z ed      d        Z ed      d        Z ed      d        Z ed      d         Z ed!      d"        Z ed#      d$        Z ed%      d&        Z ed'      d(        Z  ed)      d*        Z! ed+      d,        Z" ed-      d.        Z# ed/      d0        Z$ ed1      d2        Z% ed3      d4        Z& ed5      d6        Z' ed7      d8        Z( ed9      d:        Z) ed;      d<        Z* ed=      d>        Z+ ed?      d@        Z, edA      dB        Z- edC      dD        Z. edE      dF        Z/ edG      dH        Z0 edI      dJ        Z1 edK      dL        Z2 edM      dN        Z3 edO      dP        Z4 edQ      dR        Z5 edS      dT        Z6 edU      dV        Z7 edW      dX        Z8 edY      dZ        Z9 ed[      d\        Z: ed]      d^        Z; ed_      d`        Z< eda      db        Z= edc      dd        Z> ede      df        Z? edg      dh        Z@ edi      dj        ZA edk      dl        ZB edm      dn        ZC edo      dp        ZD	 d d	lEZF edq      dr        ZG eds      dt        ZH edu      dv        ZI edw      dx        ZJy	# eK$ r Y y	w xY w){    )annotations)Iterable)contextmanager   )*)_GlobalDebug)register_type_casterregister_value_casterglobals)get_dialect_registryappend_load_on_create_dialectget_load_on_create_dialectsN)	max_depthc              #    K   t        j                         }t        j                         }| |n| } 	 t        j                  |        |st        j                  d       d |st        j                  d       t        j                  |       y# |st        j                  d       t        j                  |       w xY ww)a=  Enables automatic traceback-based locations for MLIR operations.

    Operations created within this context will have their location
    automatically set based on the Python call stack.

    Args:
      max_depth: Maximum number of frames to include in the location.
        If None, the default limit is used.
    NTF)_globalsloc_tracebacks_enabledloc_tracebacks_frame_limitset_loc_tracebacks_frame_limitset_loc_tracebacks_enabled)r   old_enabled	old_limits      I/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jaxlib/mlir/ir.pyloc_tracebacksr      s      113K335I&.	II;//	://5//6//	: //6//	:s   /C 0B "-C .B==C c                      fd}|S )Nc                8    t         j                  |        | S )N)replace)AttrBuilderinsert)funckindr   s    r   decorator_builderz5register_attribute_builder.<locals>.decorator_builder3   s    4w7     )r    r   r!   s   `` r   register_attribute_builderr$   2   s     r"   AffineMapAttrc                ,    t         j                  |       S N)r%   getxcontexts     r   _affineMapAttrr,   :   s    Qr"   IntegerSetAttrc                ,    t         j                  |       S r'   )r-   r(   r)   s     r   _integerSetAttrr/   ?   s    a  r"   BoolAttrc                0    t         j                  | |      S Nr+   )r0   r(   r)   s     r   	_boolAttrr4   D       <<7<++r"   DictionaryAttrc                0    t         j                  | |      S r2   )DictAttrr(   r)   s     r   	_dictAttrr9   I   r5   r"   	IndexAttrc                V    t         j                  t        j                  |      |       S r2   )IntegerAttrr(   	IndexTyper)   s     r   
_indexAttrr>   N   s    ??9===91==r"   I1Attrc                X    t         j                  t        j                  d|      |       S Nr   r3   r<   r(   IntegerTypeget_signlessr)   s     r   _i1AttrrE   S   #    ??;33Aw3GKKr"   I8Attrc                X    t         j                  t        j                  d|      |       S N   r3   rB   r)   s     r   _i8AttrrK   X   rF   r"   I16Attrc                X    t         j                  t        j                  d|      |       S N   r3   rB   r)   s     r   _i16AttrrP   ]   #    ??;33B3H!LLr"   I32Attrc                X    t         j                  t        j                  d|      |       S N    r3   rB   r)   s     r   _i32AttrrV   b   rQ   r"   I64Attrc                X    t         j                  t        j                  d|      |       S N@   r3   rB   r)   s     r   _i64Attrr[   g   rQ   r"   SI1Attrc                X    t         j                  t        j                  d|      |       S rA   r<   r(   rC   
get_signedr)   s     r   _si1Attrr`   l   #    ??;11!W1EqIIr"   SI8Attrc                X    t         j                  t        j                  d|      |       S rI   r^   r)   s     r   _si8Attrrd   q   ra   r"   SI16Attrc                X    t         j                  t        j                  d|      |       S rN   r^   r)   s     r   	_si16Attrrg   v   #    ??;11"g1FJJr"   SI32Attrc                X    t         j                  t        j                  d|      |       S rT   r^   r)   s     r   	_si32Attrrk   {   rh   r"   SI64Attrc                X    t         j                  t        j                  d|      |       S rY   r^   r)   s     r   	_si64Attrrn      rh   r"   UI1Attrc                X    t         j                  t        j                  d|      |       S rA   r<   r(   rC   get_unsignedr)   s     r   _ui1Attrrs      rF   r"   UI8Attrc                X    t         j                  t        j                  d|      |       S rI   rq   r)   s     r   _ui8Attrrv      rF   r"   UI16Attrc                X    t         j                  t        j                  d|      |       S rN   rq   r)   s     r   	_ui16Attrry      rQ   r"   UI32Attrc                X    t         j                  t        j                  d|      |       S rT   rq   r)   s     r   	_ui32Attrr|      rQ   r"   UI64Attrc                X    t         j                  t        j                  d|      |       S rY   rq   r)   s     r   	_ui64Attrr      rQ   r"   F32Attrc                0    t         j                  | |      S r2   )	FloatAttrget_f32r)   s     r   _f32Attrr          Q00r"   F64Attrc                0    t         j                  | |      S r2   )r   get_f64r)   s     r   _f64Attrr      r   r"   StrAttrc                0    t         j                  | |      S r2   
StringAttrr(   r)   s     r   _stringAttrr          >>!W>--r"   SymbolNameAttrc                0    t         j                  | |      S r2   r   r)   s     r   _symbolNameAttrr      r   r"   SymbolRefAttrc                ~    t        | t              rt        j                  | |      S t        j                  | |      S r2   )
isinstancelistr   r(   FlatSymbolRefAttrr)   s     r   _symbolRefAttrr      s8    !T  G 44 $$Q$88r"   r   c                0    t         j                  | |      S r2   )r   r(   r)   s     r   _flatSymbolRefAttrr            G 44r"   UnitAttrc                4    | rt         j                  |      S y r2   )r   r(   r)   s     r   	_unitAttrr      s    ||G|,,r"   	ArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   
_arrayAttrr      s    ==G=,,r"   AffineMapArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r,   r*   r+   vs      r   _affineMapArrayAttrr      &    ==a@.G4@AA@   .BoolArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r4   r   s      r   _boolArrayAttrr      &    ==;A)Aw/;<<;r   DictArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r9   r   s      r   _dictArrayAttrr      r   r   FlatSymbolRefArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r   r   s      r   _flatSymbolRefArrayAttrr      s'    ==!DQ,Q8DEEDr   I32ArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   rV   r   s      r   _i32ArrayAttrr      &    ==:1(1g.:;;:r   I64ArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r[   r   s      r   _i64ArrayAttrr      r   r   I64SmallVectorArrayAttrc                    t        | |      S r2   )r   r)   s     r   _i64SmallVectorArrayAttrr      s    G,,r"   IndexListArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r   r   s      r   _indexListArrayAttrr      s&    ==Q?-73?@@?r   F32ArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r   r   s      r   _f32ArrayAttrr      r   r   F64ArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r   r   s      r   _f64ArrayAttrr      r   r   StrArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r   r   s      r   _strArrayAttrr      s&    ==1=a+a1=>>=r   SymbolRefArrayAttrc           	     f    t         j                  | D cg c]  }t        ||       c}      S c c}w r'   )r   r(   r   r   s      r   _symbolRefArrayAttrr     r   r   DenseF32ArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   _denseF32ArrayAttrr     r   r"   DenseF64ArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   _denseF64ArrayAttrr     r   r"   DenseI8ArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   _denseI8ArrayAttrr     s    733r"   DenseI16ArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   _denseI16ArrayAttrr     r   r"   DenseI32ArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   _denseI32ArrayAttrr     r   r"   DenseI64ArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   _denseI64ArrayAttrr   !  r   r"   DenseBoolArrayAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   _denseBoolArrayAttrr   &  s    !!!W!55r"   TypeAttrc                0    t         j                  | |      S r2   )r   r(   r)   s     r   	_typeAttrr   +  r5   r"   TypeArrayAttrc           	     j    t        | D cg c]  }t        j                  ||       c}|      S c c}w r2   )r   r   r(   )r*   r+   ts      r   _typeArrayAttrr   0  s*    CAx||Aw|7CWMMCs   0MemRefTypeAttrc                    t        | |      S r'   )r   r)   s     r   _memref_type_attrr   5  s    Q  r"   F64ElementsAttrc                    t         j                  t        j                  | t        j                        t
        j                  |      |      S Ndtyper3   typer+   )DenseElementsAttrr(   nparrayfloat64F64Typer)   s     r   _f64ElementsAttrr   =  s=     $$HHQbjj)W- % 
 	
r"   I32ElementsAttrc                    t         j                  t        j                  | t        j                        t
        j                  d|      |      S )Nr   rU   r3   r   )r   r(   r   r   int32rC   rD   r)   s     r   _i32ElementsAttrr   E  B     $$HHQbhh'))"g)> % 
 	
r"   I64ElementsAttrc                    t         j                  t        j                  | t        j                        t
        j                  d|      |      S )Nr   rZ   r3   r   )r   r(   r   r   int64rC   rD   r)   s     r   _i64ElementsAttrr   M  r   r"   IndexElementsAttrc                    t         j                  t        j                  | t        j                        t
        j                  |      |      S r   )r   r(   r   r   r   r=   r)   s     r   _indexElementsAttrr  U  s=     $$HHQbhh'w/ % 
 	
r"   )r   z
int | NonereturnzIterable[None])F)L
__future__r   collections.abcr   
contextlibr   _mlir_libs._mlir.irr   _mlir_libs._mlirr	   r
   r   r   
_mlir_libsr   r   r   r   r$   r,   r/   r4   r9   r>   rE   rK   rP   rV   r[   r`   rd   rg   rk   rn   rs   rv   ry   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   numpyr   r   r   r   r  ImportErrorr#   r"   r   <module>r     s  
 # $ % " - 
  .2 ; ;2 O,  -  ,-! .! J', (, ,-, ., K(> )> H%L &L H%L &L I&M 'M I&M 'M I&M 'M I&J 'J I&J 'J J'K (K J'K (K J'K (K I&L 'L I&L 'L J'M (M J'M (M J'M (M I&1 '1 I&1 '1 I&. '. ,-. .. O,9 -9 /05 15 J' ( K(- )- 01B 2B O,= -= O,= -= 45F 6F N+< ,< N+< ,< 56- 7- 01A 2A N+< ,< N+< ,< N+? ,? 01B 2B /05 15 /05 15 ./4 04 /05 15 /05 15 /05 15 016 26 J', (, O,N -N ,-! .!$	 12
 3
   12
 3
   12
 3
   34
 5
  		s   ?<L< <MM