Ë
    ßGìjZr  ã            
      óÎ  — d dl mZ d dlmZmZmZ d dlZd dlZd dlZd dl	Z	d dl
mZmZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dl m!Z! d dl"m#Z#m$Z$m%Z%m&Z&m'Z' ejP                  e)cZ)Z*ee+   ez  dz  Z,	 	 d5	 	 	 	 	 	 	 	 	 	 	 d6d„Z-	 d7	 	 	 	 	 	 	 d8d„Z.d9d„Z/d„ Z0d:d„Z1d;d„Z2	 d<	 	 	 	 	 d=d„Z3dddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d>d„Z4dddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d?d„Z5e&ejl                  z  Z7d@d„Z8dAd„Z9	 	 	 	 	 	 dBd „Z:ed!d!d!d!d!d!d! e%«       d"œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dCd#„«       Z;ed!d!d!d!d!d!d! e%«       d"œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dDd$„«       Z;dddddd%d e%«       d"œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dEd&„Z;dFd'„Z<dGd(„Z= G d)„ d*«      Z> ej~                  d+¬,«       G d-„ d.ej€                  «      «       ZA eA«       ZBej†                  j‰                  eA«       ejŠ                  j‰                  eA«       	 	 	 	 dHd/„ZFd0„ ZGd1„ ZH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dId2„ZI	 	 	 	 	 	 dJd3„ZJ ej–                  d4«      ZLd+eL_M         ejœ                  eL«       eLjŸ                  eF«       eGej                   eL<   eHej¢                  eL<    ej¤                  eJeL«      ej¦                  eL<    ej¨                  eLeI«       y)Ké    )Úannotations)ÚCallableÚMappingÚSequenceN)ÚAnyÚoverload)Úcore)Údispatch)Úeffects)Úutil)Ú
xla_bridge)ÚHashableArray)Úad)Úbatching)Úmlir)ÚLayout)Újaxlib)Ú
xla_client)Úir)ÚArrayÚ	ArrayLikeÚDeprecatedArgÚDuckTypedArrayÚShapec                ó4   — t        j                  | |||fi |¤ŽS )až  Registers a foreign function target.

  Args:
    name: the name of the target.
    fn: a ``PyCapsule`` object containing the function pointer, or a ``dict``
      where the keys are FFI stage names (e.g. `"execute"`) and the values are
      ``PyCapsule`` objects containing a pointer to the handler for that stage.
    platform: the target platform.
    api_version: the XLA custom call API version to use. Supported versions are:
      1 (default) for the typed FFI or 0 for the earlier "custom call" API.
    kwargs: any extra keyword arguments are passed directly to
      :func:`~jaxlib.xla_client.register_custom_call_target` for more advanced
      use cases.
  )r   Úregister_custom_call_target)ÚnameÚfnÚplatformÚapi_versionÚkwargss        úPC:\Users\Stabi\Downloads\virtual-tryon(1)\venv\Lib\site-packages\jax/_src/ffi.pyÚregister_ffi_targetr#   .   s'   € ô* 
×	/Ñ	/°°b¸(ÀKñ 
:Ø28ñ
:ð :ó    c                ó2   — t        j                  | ||¬«      S )zóRegisters a custom type ID for a FFI target.

  Args:
    name: the name of the type ID. This name must be unique within the process.
    obj: a ``PyCapsule`` object encapsulating a pointer to the type ID.
    platform: the target platform.
  )r   )r   Úregister_custom_type_id)r   Úobjr   s      r"   Úregister_ffi_type_idr(   G   s   € ô 
×	+Ñ	+¨D°#ÀÔ	IÐIr$   c                óœ   — t        j                  | «       t        j                  t	        j
                  t         j                  | «      «       y)z]Registers an FFI target as batch partitionable.

  Args:
    name: the name of the target.
  N)r   Ú+register_custom_call_as_batch_partitionabler   Úregister_plugin_callbacksÚ	functoolsÚpartial)r   s    r"   Ú*register_ffi_target_as_batch_partitionabler.   V   s9   € ô ×8Ñ8¸Ô>Ü×&Ñ&Ü×Ñœ
×NÑNØóõr$   c                ó  — t        j                  dt         j                  «      }t         j                  j                  }t         j                  |_        t         j                  t         j                  |f|_         || d |d«      «      S )aÍ  Wrap a ctypes function pointer in a PyCapsule.

  The primary use of this function, and the reason why it lives with in the
  ``jax.ffi`` submodule, is to wrap function calls from external compiled
  libraries to be registered as XLA custom calls.

  Example usage::

    import ctypes
    import jax
    from jax.lib import xla_client

    libfoo = ctypes.cdll.LoadLibrary('./foo.so')
    xla_client.register_custom_call_target(
        name="bar",
        fn=jax.ffi.pycapsule(libfoo.bar),
        platform=PLATFORM,
        api_version=API_VERSION
    )

  Args:
    funcptr: A function pointer loaded from a dynamic library using ``ctypes``.

  Returns:
    An opaque ``PyCapsule`` object wrapping ``funcptr``.
  Nr   )	ÚctypesÚ	CFUNCTYPEÚ	py_objectÚ	pythonapiÚPyCapsule_NewÚrestypeÚc_void_pÚc_char_pÚargtypes)ÚfuncptrÚ
destructorÚbuilders      r"   Ú	pycapsuler<   b   sd   € ô6 ×Ñ ¤f×&6Ñ&6Ó7€*Ü×Ñ×*Ñ*€'Ü×$Ñ$€'„/Ü—o‘o¤v§¡¸
ÐC€'ÔÙ	�˜$¡
¨1£Ó	.Ð.r$   c                 óÖ   — t         j                  j                  t         j                  j                  t        j
                  «      «      } t         j                  j                  | d«      S )zIGet the path to the directory containing header files bundled with jaxlibÚinclude)ÚosÚpathÚdirnameÚabspathr   Ú__file__Újoin)Ú
jaxlib_dirs    r"   Úinclude_dirrF   „   s:   € ä�w‰w�‰œrŸw™wŸ™¬v¯©Ó?Ó@€*Ü	�‰�‰�j )Ó	,Ð,r$   c                óh   — | t         j                  u rdS t        j                  | «      j                  S ©N© )r	   Úabstract_tokenÚphysical_avalÚshape)Úavals    r"   Ú_aval_shaperN   Š   s+   € Ø”t×*Ñ*Ñ*ˆÐN´×0BÑ0BÀ4Ó0H×0NÑ0NÐNr$   c                óì   — |€/t        t        t        t        t	        | «      «      «      «      «      S t        |t        «      r)|j                  �t        d«      ‚|j                  ddd…   S t        |«      S )zIConvert a layout to the minor-to-major order used by the custom call API.Nz,The FFI does not support layouts with tilingéÿÿÿÿ)
ÚtupleÚreversedÚrangeÚlenrN   Ú
isinstancer   ÚtilingÚ
ValueErrorÚmajor_to_minor)rM   Úlayouts     r"   Ú_convert_layout_for_loweringrZ   Ž   sg   € ð €^Ü”œ%¤¤K°Ó$5Ó 6Ó7Ó8Ó9Ð9Ü�&œ&Ô!Ø‡}�}Ð ÜÐEÓFÐFØ× Ñ ¡ 2 Ñ&Ð&ä�‹=Ðr$   F©Úoperand_layoutsÚresult_layoutsÚbackend_configÚskip_ffi_layout_processingc               ó8   ‡ ‡‡‡‡‡— 	 	 	 	 	 	 	 	 dˆˆ ˆˆˆˆfd„}|S )a<  Build a lowering op for an foreign function interface (FFI) target.

  By default, this lowering rule can use the input and output abstract values to
  compute the input and output types and shapes for the custom call, assuming
  row-major layouts.

  Note that layouts passed to this function as tuples should be in
  minor-to-major order (as expected by XLA) rather than major-to-minor as used
  by :func:`~jax.ffi.ffi_call` and ``Layout``.

  If keyword arguments are passed to the lowering rule, these are treated as
  attributes, and added to `backend_config`.

  Args:
    call_target_name: The name of the custom call target.
    operand_layouts: A sequence of layouts (dimension orders) for each operand.
      By default, the operands are assumed to be row-major.
    result_layouts: A sequence of layouts (dimension orders) for each result.
      By default, the results are assumed to be row-major.
    backend_config: Configuration data for the custom call. Any keyword
      arguments passed to the lowering rule will added to this dictionary.
    lowering_args: Any other arguments to :func:`mlir.custom_call` will also be
      passed through if provided as extra arguments to this function.
    skip_ffi_layout_processing: If true, skip processing of operand and result
      layout arguments passed to the lowering rule.
  c                ó*  •— t        ‰
«      }|j                  dd«       |d   dk\  rf‰�t        ‰t         «      st        d«      ‚t        ‰xs i fi |j	                  «       D ��ci c]  \  }}|t        j                  |«      “Œ c}}¤Ž|d<   n|rt        d|d   › d�«      ‚‰|d<   d|vr0| j                  D �cg c]  }t        j                  |«      ‘Œ c}|d<   ‰sš‰€t        t        | j                  «      |d<   n-t        | j                  ‰«      D �cg c]
  }t        |Ž ‘Œ c}|d<   ‰€t        t        | j                  «      |d	<   n-t        | j                  ‰«      D �cg c]
  }t        |Ž ‘Œ c}|d	<   d
|vrit        d„ | j                  D «       «      sM| j                  D �cg c]4  }t        j                  t        j                  | t!        |«      «      «      ‘Œ6 c}|d
<   t        j"                  ‰	fd|i|¤ŽS c c}}w c c}w c c}w c c}w c c}w )Nr    é   z:When api_version > 4, backend_config must be a dictionary.r^   zaThe use of ffi_call attributes requires a custom call API version of at least 4; got api_version=Ú.Úresult_typesr\   r]   Úresult_shapesc              3  óX   K  — | ]"  }t        j                  t        |«      «      –— Œ$ y ­w©N)r	   Úis_constant_shaperN   )Ú.0rM   s     r"   Ú	<genexpr>zDbuild_ffi_lowering_function.<locals>._lowering_op.<locals>.<genexpr>å   s%   è ø€ ð 1MÙ>K°dŒ×Ñœ{¨4Ó0×1¹mùs   ‚(*Úoperands)ÚdictÚ
setdefaultrU   rW   Úitemsr   Úir_attributeÚ	avals_outÚaval_to_ir_typeÚmaprZ   Úavals_inÚzipÚallÚshape_tensorÚeval_dynamic_shape_as_ivalsrN   Úcustom_call)Úctxrk   Úparamsr!   ÚkÚvrM   Úargsr^   Úcall_target_nameÚlowering_argsr\   r]   r_   s           €€€€€€r"   Ú_lowering_opz1build_ffi_lowering_function.<locals>._lowering_op¿   sR  ø€ ô �-Ó €FØ
×Ñ�m QÔ'ØˆmÑ Ò!Ø	Ð	#¬J°~ÄtÔ,LÜØHóJð 	Jä!%ØÒ˜"ñ"VØEKÇ\Á\Ä^Ô TÁ^¹T¸QÀ ¤D×$5Ñ$5°aÓ$8Ñ!8À^Ò Tñ"V€fÐÒñ 
Üð.Ø.4°]Ñ.CÐ-DÀAðGóHð 	Hð "0€fÐÑØ˜VÑ#ØGJÇ}Â}ÓUÁ}¸t¤× 4Ñ 4°TÕ :À}ÑU€fˆ^ÑÙ%Ø	Ð	 Ü$'Ü(¨#¯,©,ó%
ˆÐ Ò!ô ˜CŸL™L¨/Ô:ó%
á:�ô )¨$Ò/Ø:ñ%
ˆÐ Ñ!ð 
Ð	Ü#&Ü(¨#¯-©-ó$
ˆÐÒ ô ˜CŸM™M¨>Ô:ó$
á:�ô )¨$Ò/Ø:ñ$
ˆÐÑ ð ˜fÑ$¬Sñ 1MØ>A¿mºmó1Mô .Mð —m’mó!%á#ˆdô ×
Ñ
œD×<Ñ<¸SÄ+ÈdÓBSÓTÕ
UØ#ñ!%€fˆ_Ñô ×ÑÐ,ÑJ°xÐJÀ6ÑJÐJùóE !Uùò  Vùò%
ùò$
ùò!%s   Á# G;Â8HÄHÅ!HÆ$9H)ry   úmlir.LoweringRuleContextrk   úir.Valuerz   r   Úreturnzir.OperationrI   )r~   r\   r]   r^   r_   r   r€   s   `````` r"   Úbuild_ffi_lowering_functionr„   ›   s=   ý€ ðH,KØ	!ð,KØ.6ð,KØBEð,Kà÷,Kò ,Kð\ 
Ðr$   c               ó8   ‡ ‡‡‡‡‡— 	 	 	 	 	 	 	 	 dˆˆ ˆˆˆˆfd„}|S )a>  Build a lowering rule for an foreign function interface (FFI) target.

  By default, this lowering rule can use the input and output abstract values to
  compute the input and output types and shapes for the custom call, assuming
  row-major layouts.

  Note that layouts passed to this function as tuples should be in
  minor-to-major order (as expected by XLA) rather than major-to-minor as used
  by :func:`~jax.ffi.ffi_call` and ``Layout``.

  If keyword arguments are passed to the lowering rule, these are treated as
  attributes, and added to `backend_config`.

  Args:
    call_target_name: The name of the custom call target.
    operand_layouts: A sequence of layouts (dimension orders) for each operand.
      By default, the operands are assumed to be row-major.
    result_layouts: A sequence of layouts (dimension orders) for each result.
      By default, the results are assumed to be row-major.
    backend_config: Configuration data for the custom call. Any keyword
      arguments passed to the lowering rule will added to this dictionary.
    lowering_args: Any other arguments to :func:`mlir.custom_call` will also be
      passed through if provided as extra arguments to this function.
    skip_ffi_layout_processing: If true, skip processing of operand and result
      layout arguments passed to the lowering rule.
  c           	     óR   •—  t        ‰f‰‰‰‰	dœ‰¤Ž| g|¢­i |¤Ž}|j                  S )Nr[   )r„   Úresults)
ry   rk   rz   Úresultr^   r~   r   r\   r]   r_   s
       €€€€€€r"   Ú	_loweringzffi_lowering.<locals>._lowering  sZ   ø€ ðÔ(Øðà'Ø%Ø%Ø#=ñð ñð 
ð ð ò ð ñ €Fð �>‰>Ðr$   )ry   r�   rk   r‚   rz   r   rƒ   z'Sequence[ir.Value | Sequence[ir.Value]]rI   )r~   r\   r]   r^   r_   r   r‰   s   `````` r"   Úffi_loweringrŠ   ð   s6   ý€ ðHØ	!ðØ.6ðØBEðà.÷ò ð 
Ðr$   c                ó`  — g }t        | «      D ]”  \  }}t        |t        j                  «      r|j	                  |«       Œ2t        |d«      rt        |d«      st        d|› d|› d�«      ‚|j	                  t        j                  |j                  |j                  «      «       Œ– t        |«      S )NrL   ÚdtypezRAll elements of result_shape_dtypes must have 'shape' and 'dtype' attributes. Got z at position rc   )Ú	enumeraterU   r	   ÚAbstractTokenÚappendÚhasattrrW   ÚShapedArrayrL   rŒ   rQ   )r‡   ÚavalsÚidxrˆ   s       r"   Ú_result_avalsr”   (  sœ   € Ø$&€%Ü˜wÖ'�k€cˆ6Ü�&œ$×,Ñ,Ô-Ø‡l�l�6Õä�V˜WÔ%¬W°V¸WÔ-EÜðØ%˜h m°C°5¸ð;ó<ð 	<ð ‡l�l”4×#Ñ# F§L¡L°&·,±,Ó?Õ@ð (ô 
ˆu‹Ðr$   c                óÞ   — t        | t        j                  «      rt        |t        j                  «      ryt        | dd«      t        |dd«      k7  ryt        | dd«      t        |dd«      k7  ryy)NTrL   rI   FrŒ   )rU   r	   rŽ   Úgetattr)ÚaÚbs     r"   Ú_check_compatible_avalsr™   6  sa   € Ü�”4×%Ñ%Ô&¬:°a¼×9KÑ9KÔ+LØÜˆQ�˜Ó¤¨¨7°BÓ 7Ò7ØÜˆQ�˜Ó¤¨¨7°BÓ 7Ò7ØØ	r$   c                ó:   — t        d„ t        | |«      D «       «      S )Nc              3  ón   K  — | ]-  \  }}t        ||�t        |t        «      r|n|d d d…   «      –— Œ/ y ­w)NrP   )rZ   rU   r   )ri   rM   rY   s      r"   rj   z0_convert_layouts_for_ffi_call.<locals>.<genexpr>C  sC   è ø€ ð /ñ .‰,ˆ$�ô #Ø
Ø�N¤j°¼Ô&@‰&Ø‘d˜�d‰|÷ñ
 .ùs   ‚35)rQ   rt   )r’   Úlayoutss     r"   Ú_convert_layouts_for_ffi_callr�   @  s'   € ô 
ñ /ô ˜e WÔ-ó/ó 
/ð /r$   .)Úhas_side_effectÚvmap_methodÚinput_layoutsÚoutput_layoutsÚinput_output_aliasesÚcustom_call_api_versionÚlegacy_backend_configÚ
vectorizedc                ó   — y rg   rI   ©
Útarget_nameÚresult_shape_dtypesrž   rŸ   r    r¡   r¢   r£   r¤   r¥   s
             r"   Úffi_callrª   M  ó   € ð r$   c                ó   — y rg   rI   r§   s
             r"   rª   rª   ^  r«   r$   rb   c               ó2  ‡ ‡‡‡‡‡‡‡‡‡‡— t        |	t        «      st        d«      ‚g d¢}
‰|
vrt        d|
› d‰› �«      ‚t        ‰t        «      r|ŠdŠt	        ‰«      ŠndŠt	        ‰f«      Š|fŠ‰dk\  r‰�t        d‰› d	�«      ‚dˆˆˆˆˆˆˆˆˆˆ ˆfd
„}|S )a¬  Call a foreign function interface (FFI) target.

  See the :ref:`ffi-tutorial` tutorial for more information.

  Like :func:`~jax.pure_callback`, the behavior of ``ffi_call`` under
  :func:`~jax.vmap` depends on the value of ``vmap_method``. See the
  :func:`~jax.pure_callback` documentation for more details about the allowed
  values and examples of their behavior.

  The current default behavior is to use ``vmap_method="sequential"`` when
  not specified, but this behavior is deprecated, and in the future, the
  default will be to raise a ``NotImplementedError`` unless ``vmap_method`` is
  explicitly specified.

  Args:
    target_name: the name of the XLA FFI custom call target that was registered
      using :func:`~jax.ffi.register_ffi_target`.
    result_shape_dtypes: an object, or sequence of objects, with ``shape`` and
      ``dtype`` attributes which are expected to match the shape and dtype of
      the custom call output or outputs. :class:`~jax.ShapeDtypeStruct` is often
      used to define the elements of ``result_shape_dtypes``.
      ``jax.core.abstract_token`` may be used to represent a token-typed output.
    has_side_effect: boolean specifying whether the custom call has side
      effects. When ``True``, the FFI call will be executed even when the
      outputs are not used.
    vmap_method: string specifying how the FFI call transforms under
      :func:`~jax.vmap` as described above.
    input_layouts: a sequence of layouts for each input argument. In each case,
      the layout can be (a) ``None`` indicating that this input is in default
      row-major order, (b) a ``Layout`` specifying the axis order,
      or (c) a sequence of integers specifying the major-to-minor axis
      ordering. Users who are familiar with XLA layouts should note that this
      function expects layouts in major-to-minor order instead of the
      minor-to-major order that XLA uses. For example, a batch of row-major
      matrices could be specified using the layout ``[0, 1, 2]``, whereas a
      batch of column-major matrices would have layout ``[0, 2, 1]``. In both
      of these examples, the leading/batch dimension is the "slowest" axis. The
      ``input_layouts`` parameter should be used to request the memory layout
      expected by the FFI call target, and XLA will ensure that the buffers
      have the correct layouts before the handler is executed.
    output_layouts: like ``input_layouts``, but specifying the required layouts
      for the output arrays.
    input_output_aliases: a dictionary where the keys are input indices and the
      values are output indices. This mapping indicates which output arrays
      alias specific input arrays.
    custom_call_api_version: the version number of the custom call API
      implemented by the FFI target ``target_name``. The only formally
      supported version is the typed FFI API with ``custom_call_api_version=4``,
      but earlier unsupported custom calls can be executed using this argument.
    legacy_backend_config: for legacy targets implemented using
      ``custom_call_api_version<4``, attributes are passed using the opaque
      string representation provided by this argument. This parameter cannot be
      used with ``custom_call_api_version>=4``.

  Returns:
    A function that can be called with the input arrays as positional arguments
    to execute the FFI handler. Any keyword arguments are passed as named
    attributes to the FFI handler using XLA's FFI interface.
  zcThe 'vectorized' argument of jax.ffi.ffi_call was removed in JAX v0.6.0. Use 'vmap_method' instead.)Ú
sequentialÚsequential_unrolledÚexpand_dimsÚbroadcast_allÚlegacy_vectorizedNz.vmap_method must be on of the allowed methods z, but got: TFrb   zYThe use of the legacy_backend_config parameter requires custom_call_api_version < 4; got rc   c                 óˆ  •— | D �cg c]  }t        j                  |«      ‘Œ }}‰€t        t        t        |«      «      }nGt        ‰«      t        |«      k7  r$t        dt        |«      › dt        ‰«      › d�«      ‚t        |‰«      }‰€t        t        t        ‰«      «      }nGt        ‰«      t        ‰«      k7  r$t        dt        ‰«      › dt        ‰«      › d�«      ‚t        ‰‰«      }d}‰�ôt        ‰j                  «       «      D ]Ø  \  }}t        |«      t        |«      }}|t        | «      k\  r!t        d|› d|› d	|› d
t        | «      › d�	«      ‚|t        ‰«      k\  r!t        d|› d|› d|› d
t        ‰«      › d�	«      ‚||   }	‰|   }
t        |	|
«      st        d|› d|› d|	› d|
› d�	«      ‚||   ||   k7  rt        d|› d|› d||   › d||   › d�	«      ‚|||ffz  }ŒÚ t        j                  | Ž } t        j                  | ‰‰‰‰|||‰‰t        |«      dœ
Ž}‰rt!        ‰t        «      rt        |«      S |S |d   S c c}w )NzThe number of input arguments (z*) must equal the number of input layouts (z).zThe number of outputs (z+) must equal the number of output layouts (rI   z+input_output_aliases contains the mapping 'Ú:z' with input index z outside the range [0, z' with output index z,' referring to an input with abstract value z/ and an output with a different abstract value rc   z$' referring to an input with layout z' and an output with a different layout )
Úresult_avalsrŸ   r¨   rž   r    r¡   r¢   r£   r¤   Ú
attributesr   )r	   Úget_avalrQ   rr   rZ   rT   rW   r�   Úsortedrn   Úintr™   Ústandard_insert_pvaryÚ
ffi_call_pÚbindÚ_wrap_kwargs_hashablerU   )r}   r!   ÚxÚin_avalsÚstatic_input_layoutsÚstatic_output_layoutsÚstatic_input_output_aliasesÚi_idxÚo_idxÚin_avalÚout_avalr‡   r£   rž   r    r¢   r¤   Úmultiple_resultsÚoutput_layouts_rµ   r©   r¨   rŸ   s               €€€€€€€€€€€r"   Úwrappedzffi_call.<locals>.wrappedÒ  s  ø€ Ù*.Ó/©$ Q”—‘˜aÕ ¨$€HÐ/àÐÜ"¤3Ô'CÀXÓ#NÓOÑä	ˆ]Ó	œs 8›}Ò	,ÜØ-¬c°(«m¨_ð =(Ü(+¨MÓ(:Ð';¸2ð?ó@ð 	@ô ;¸8Ø;HóJÐàÐÜ#¤CÔ(DØ(4ó%6ó 7Ñô 
ˆ_Ó	¤ \Ó!2Ò	2ÜØ%¤c¨,Ó&7Ð%8ð 9)Ü),¨_Ó)=Ð(>¸bðBóCð 	Cô <¸LØ<KóMÐð @BÐØÐ'Ü Ð!5×!;Ñ!;Ó!=Ö>‰,ˆ%�Ü˜5“z¤3 u£:ˆuˆØ”C˜“IÒÜØ;¸E¸7À!ÀEÀ7ð K"Ø"' Ð(?Ü�T“�˜2ðó ð  ð ”C˜Ó%Ò%ÜØ;¸E¸7À!ÀEÀ7ð K#Ø#( 'Ð)@Ü�\Ó"Ð# 2ð'ó(ð (ð ˜5‘/ˆØ Ñ&ˆÜ& w°Ô9ÜØ;¸E¸7À!ÀEÀ7ð K;Ø;B¸)ð D8Ø8@°zÀðDóEð Eð   Ñ&Ð*?ÀÑ*FÒFÜØ;¸E¸7À!ÀEÀ7ð K3Ø3GÈÑ3NÐ2Oð P7à& uÑ-Ð.¨að1ó2ð 2ð
 	$¨°¨Ð'8Ñ8Ñ#ð3 ?ô4 ×%Ñ% tÐ,€DÜ�o‰oØ	Ø!ØØØ'Ø*Ø,Ø8Ø 7Ø3Ü(¨Ó0ò€Gñ Ü	Ð'¬Ô	/Ü�W‹~ÐØ€nà�Q‰ZÐùòK 0s   †H?)r}   r   r!   r   )rU   r   rW   r   r”   )r¨   r©   rž   rŸ   r    r¡   r¢   r£   r¤   r¥   Úallowed_vmap_methodsrÉ   rÇ   rÈ   rµ   s   ````` ```   @@@r"   rª   rª   o  sÞ   ÿú€ ôR 
�J¤Ô	.Ü
ð	-ó.ð .òFÐàÐ,Ñ,Ü
Ø
8Ð9MÐ8Nð OØ�=ð	"ó#ð #ô
 Ð#¤XÔ.Ø$€OØÐÜ Ð!4Ó5�LàÐÜ Ð"5Ð!7Ó8€LØ%Ð'€Oà Ò!Ð&;Ð&GÜ
ð	,Ø,CÐ+DÀAð	GóHð H÷F÷ FðP 
€.r$   c                óª  — g }t        | j                  «       «      D ]ˆ  \  }}t        |t        j                  «      r|j                  |t        |«      f«       Œ=t        |t        «      r|j                  |t        |«      f«       Œj	 t        |«       |j                  ||f«       ŒŠ t        |«      S # t        $ r}t        d|› d|› �«      |‚d }~ww xY w)Nz*Non-hashable keyword argument to ffi_call z: )r¸   rn   rU   ÚnpÚndarrayr�   r   rl   ÚHashableDictÚhashÚ	TypeErrorrQ   )r!   Úhashable_kwargsr{   r|   Úes        r"   r½   r½   "  sÊ   € Ø+-€/Ü�V—\‘\“^Ö$�d€aˆÜ�!”R—Z‘ZÔ Ø×Ñ˜a¤¨qÓ!1Ð2Õ3Ü	�A”tÔ	Ø×Ñ˜a¤¨a£Ð1Õ2ð'ÜˆQŒð
 	×Ñ  1˜vÕ&ð %ô 
ˆÓ	Ðøô ò JÜØ8¸¸¸2¸a¸SÐAóCØHIð	JûðJús   ÂB2Â2	CÂ;CÃCc                óº   — i }| D ]S  \  }}t        |t        «      r|j                  ||<   Œ&t        |t        «      rt	        |j                  «      ||<   ŒO|||<   ŒU |S rg   )rU   r   ÚvalrÎ   rl   )r!   Úunwrapped_kwargsr{   r|   s       r"   Ú_unwrap_kwargs_hashablerÖ   4  s_   € Ø%'ÐÛ�d€aˆÜ�!”]Ô#ØŸE™EÐ�qÒÜ	�A”|Ô	$Ü  §¡›KÐ�qÒàÐ�qÒð ð 
Ðr$   c                  ó*   — e Zd ZdgZd„ Zd„ Zd„ Zd„ Zy)rÎ   rÔ   c                óv   — t        |t        «      sJ ‚t        t        |j	                  «       «      «      | _        y rg   )rU   rl   rQ   r¸   rn   rÔ   )ÚselfrÔ   s     r"   Ú__init__zHashableDict.__init__C  s)   € Ü�cœ4Ô Ð Ð Ü”V˜CŸI™I›KÓ(Ó)€D…Hr$   c                ó4   — dt        | j                  «      › d�S )NzHashableDict(Ú))rl   rÔ   ©rÙ   s    r"   Ú__repr__zHashableDict.__repr__G  s   € Øœ4 §¡›>Ð*¨!Ð,Ð,r$   c                ó,   — t        | j                  «      S rg   )rÏ   rÔ   rÝ   s    r"   Ú__hash__zHashableDict.__hash__J  s   € Ü�—‘‹>Ðr$   c                óX   — t        |t        «      xr | j                  |j                  k(  S rg   )rU   rÎ   rÔ   )rÙ   Úothers     r"   Ú__eq__zHashableDict.__eq__M  s!   € Ü�eœ\Ó*ÒD¨t¯x©x¸5¿9¹9Ñ/DÐDr$   N)Ú__name__Ú
__module__Ú__qualname__Ú	__slots__rÚ   rÞ   rà   rã   rI   r$   r"   rÎ   rÎ   @  s   „ Øˆg€)ò*ò-òóEr$   rÎ   T)Úfrozenc                  ó   — e Zd Zd„ Zy)Ú	FfiEffectc                 ó   — y)NÚFFIrI   rÝ   s    r"   Ú__str__zFfiEffect.__str__S  s   € Ør$   N)rä   rå   ræ   rí   rI   r$   r"   rê   rê   Q  s   „ ór$   rê   c                óŽ   ‡— t        j                  dg|¢­Ž Š|rt        hnt         j                  }t	        ˆfd„| D «       «      |fS )Nrª   c              3  ój   •K  — | ]*  }|t         j                  u r|n|j                  ‰¬ «      –— Œ, y­w))ÚvmaN)r	   rJ   Úupdate)ri   ÚrÚout_vmas     €r"   rj   z)ffi_call_abstract_eval.<locals>.<genexpr>d  s6   øè ø€ ð &Ù$�1ð œ×,Ñ,Ñ,‰q°!·(±(¸w°(Ó2GÓGÙ$ùs   ƒ03)r	   Ústandard_vma_ruleÚ
_FfiEffectÚ
no_effectsrQ   )rµ   rž   rs   Ú_r   ró   s        @r"   Úffi_call_abstract_evalrø   \  sK   ø€ ô ×"Ñ" :Ð9°Ò9€'Ù+ŒZ‰L´·±€'Ü	ó &Ù$ó&ó 
&Ø'.ð
/ð /r$   c                ó"   — ~t        d| › d�«      ‚©NzThe FFI call to `z\` cannot be differentiated. You can use `jax.custom_jvp` or `jax.custom_jvp` to add support.©rW   ©r¨   r}   r÷   s      r"   Úffi_call_jvprý   h  ó'   € Ø
ÜØ˜+˜ð 'Ið Ió	Jð Jr$   c                ó"   — ~t        d| › d�«      ‚rú   rû   rü   s      r"   Úffi_call_transposer   o  rþ   r$   c          	     ób   — t        ||||t        |«      ||¬«      } || g|	¢­i t        |«      ¤ŽS )N)rž   r\   r]   Úoperand_output_aliasesr    r^   )rŠ   rl   rÖ   )ry   r¨   rž   r    r¡   r¢   r£   r¤   r¶   rk   r÷   Úrules               r"   Úffi_call_loweringr  v  sD   € ô 
�k°?Ø&3Ø%3Ü-1Ð2FÓ-GØ"9Ø%:ô
<€$ñ 
ˆcÐ	D�HÒ	DÔ 7¸
Ó CÑ	DÐDr$   c          	     óú  ‡ ‡‡‡‡‡‡‡— ddl m} ddl m} t        ||«      D ��	ch c]&  \  }}	|	t        j
                  ur|j                  |	   ’Œ( c}	}\  Št        ||«      D �
�cg c]0  \  }
}|t        j
                  u r|
nt	        j                  |
|d«      ‘Œ2 }}
}t        ˆfd„‰D «       «      }‰dvr)‰j                  d«      �t        d„ ‰d   D «       «      ‰d<   ‰dk(  rJ‰j                  d	«      �"t        d
„ t        ‰d	   |«      D «       «      ‰d	<    ‰ j                  |‰|dœ‰¤Ž}�n!‰dk(  s‰dk(  r‹‰dk(  r‰nd}t        ||«      D ��	cg c],  \  }}	|	t        j
                  u r|j                  ||f«      n|‘Œ. }}}	‰j                  d	«      �t        d„ ‰d	   D «       «      ‰d	<    ‰ j                  |‰|dœ‰¤Ž}nŒ‰dk(  s‰dk(  rf|D �	cg c]  }	|	t        j
                  u‘Œ c}	Št        j                  ‰|«      \  Š}ˆˆˆ ˆˆˆfd„Š‰dk(  }ˆfd„}|j                  |d||¬«      \  }}nt        d‰ j                   › d‰›d�«      ‚t        |«      dt#        |«      z  fS c c}	}w c c}}
w c c}	}w c c}	w )Nr   )Úcontrol_flow)Úlaxc              3  óL   •K  — | ]  }t        j                  ‰d |«      –— Œ y­w)r   N)r	   Úunmapped_aval)ri   rM   Ú	axis_sizes     €r"   rj   z$ffi_batching_rule.<locals>.<genexpr>œ  s%   øè ø€ ð GÙ9E°„d×Ñ˜ A t×,¹ùs   ƒ!$)r®   r¯   r¡   c              3  óN   K  — | ]  }|€d nt        d„ |D «       «      dz   –— Œ y ­w)Nc              3  ó&   K  — | ]	  }|d z   –— Œ y­w©é   NrI   ©ri   Úns     r"   rj   z.ffi_batching_rule.<locals>.<genexpr>.<genexpr>¦  s   è ø€ Ð)@¹°A¨!¨a­%¹ùó   ‚©r   ©rQ   ©ri   rY   s     r"   rj   z$ffi_batching_rule.<locals>.<genexpr>¥  s1   è ø€ ð %0á.ˆFð �‰¤EÑ)@¹Ó)@Ó$@À4Ñ$GÓGÙ.ùó   ‚#%r²   r    c              3  ó|   K  — | ]4  \  }}|t         j                  u r|n|€d nt        d„ |D «       «      dz   –— Œ6 y ­w)Nc              3  ó&   K  — | ]	  }|d z   –— Œ y­wr  rI   r  s     r"   rj   z.ffi_batching_rule.<locals>.<genexpr>.<genexpr>¯  s   è ø€ Ð,C¹F°q¨Q°­U¹Fùr  r  )r   Ú
not_mappedrQ   )ri   rY   Úds      r"   rj   z$ffi_batching_rule.<locals>.<genexpr>­  sJ   è ø€ ð &?ñ >‰iˆf�að œ×,Ñ,Ñ,‰&Ø�>‰4¤uÑ,C¹FÓ,CÓ'CÀdÑ'JóLá=ùs   ‚:<)rŸ   rµ   r°   r±   r  c              3  óN   K  — | ]  }|€d nt        d„ |D «       «      dz   –— Œ y ­w)Nc              3  ó&   K  — | ]	  }|d z   –— Œ y­wr  rI   r  s     r"   rj   z.ffi_batching_rule.<locals>.<genexpr>.<genexpr>¾  s   è ø€ Ð+B¹6°a¨A°­E¹6ùr  r  r  r  s     r"   rj   z$ffi_batching_rule.<locals>.<genexpr>½  s1   è ø€ ð &1á/ˆfð �.‰$¤eÑ+B¹6Ó+BÓ&BÀTÑ&IÓ
IÙ/ùr  r®   r¯   c                ó\   •— t        j                  ‰‰| «      } ‰j                  |‰‰dœ‰¤ŽS )N)rµ   rŸ   )r   Úmerge_listsr¼   )Úbatched_argsÚmerged_argsÚ
is_batchedr!   Úprimrµ   Úunbatched_argsrŸ   s     €€€€€€r"   Ú
_batch_funz%ffi_batching_rule.<locals>._batch_funÉ  s=   ø€ Ü×$Ñ$ Z°ÀÓN€kØˆT�Y‰YØØ#Ø!ñð ñ	ð r$   c                ó   •— d ‰|«      fS rH   rI   )r÷   r¾   r#  s     €r"   Ú<lambda>z#ffi_batching_rule.<locals>.<lambda>Ò  s   ø€ �b™* Q›-Ñ(r$   rI   )Úunrollzvmap is only supported for the z“ primitive when vmap_method is one of 'sequential', 'sequential_unrolled', 'expand_dims', 'broadcast_all', or 'legacy_vectorized'. Got vmap_method=rc   r  )Újax._src.laxr  r  rt   r   r  rL   ÚmoveaxisrQ   Úgetr¼   Ú	broadcastr   Úpartition_listÚscanÚNotImplementedErrorr   rT   )r!  r}   ÚdimsrŸ   rµ   r!   r  r  r—   r  ÚargÚdimÚnew_argsÚbatched_result_avalsÚoutvalsÚsizer¾   Ú
bcast_argsr  r&  Úgr÷   r#  r
  r   r"  s   `  ```                @@@@r"   Úffi_batching_ruler7  Œ  sÿ  ÿ€ õ (Ýä'*¨4°¤ô 1¡™t˜q !ØœH×/Ñ/Ñ/ð —‘˜“
 ò 1�*€)ô >AÀÀt¼_ôNÙ=L±°°cð œH×/Ñ/Ñ/‰cÜ×Ñ  S¨!Ó,ñ-Ø=Lð ñ Näó GÙ9EóGó GÐð Ð>Ñ>Ø‡j�jÐ!Ó"Ð.ä$ñ %0àÐ-Ò.ó%0ó  0€FÐÑð Ð'Ò'ð ‡z�z�/Ó"Ð.Ü %ñ &?ô ˜v oÑ6¸Ô=ó&?ó !?€fˆ_Ñð ˆd�i‰iØ	ØØ)ñð ñ	‚Gð �mÒ# {°oÒ'EØ# Ò6‰9¸A€Dô ˜ $Ô'ô)á'‰DˆAˆqð &'¬(×*=Ñ*=Ñ%=ˆ�‰�a˜$˜Ô!À1ÑDØ'ð ñ )ð ‡z�z�/Ó"Ð.Ü %ñ &1à˜Ò/ó&1ó !1€fˆ_Ñð ˆd�i‰iØØØ'ñð 	ñ	�Gð �lÒ" kÐ5JÒ&JÙ8<Ó=¹°1�!œ8×.Ñ.Ò.¸Ñ=€JÜ#'×#6Ñ#6°zÀ8Ó#LÑ €N�L÷ñ ð Ð1Ñ1€FÛ(€AØ×"Ñ" 1 b¨,¸vÐ"ÓF�J€A�wä
Ø
)¨$¯)©)¨ð 5Eà8C°~ÀQð	HóIð Iô 
ˆw‹˜¤ G£Ñ,Ð	,Ð,ùóC1ùóNùó>)ùò >s   ¤+I&Á$5I,Å1I2ÇI8rª   )Úcpur  )r   Ústrr   r   r   r9  r    r¹   r!   r   rƒ   ÚNone)r8  )r   r9  r'   r   r   r9  rƒ   r:  )r   r9  rƒ   r:  )rƒ   r9  )rM   úcore.AbstractValuerƒ   r   rg   )rM   r;  rY   ÚFfiLayoutOptionsrƒ   zSequence[int])r~   r9  r\   ú!Sequence[FfiLayoutOptions] | Noner]   r=  r^   ú'Mapping[str, ir.Attribute] | str | Noner_   Úboolr   r   rƒ   zCallable[..., ir.Operation])r~   r9  r\   r=  r]   r=  r^   r>  r_   r?  r   r   rƒ   zmlir.LoweringRule)r‡   úSequence[ResultMetadata]rƒ   útuple[core.AbstractValue, ...])r—   r;  r˜   r;  rƒ   r?  )r’   zSequence[core.AbstractValue]rœ   zSequence[FfiLayoutOptions]rƒ   ztuple[Sequence[int], ...])r¨   r9  r©   ÚResultMetadatarž   r?  rŸ   ú
str | Noner    r=  r¡   ú4FfiLayoutOptions | Sequence[FfiLayoutOptions] | Noner¢   údict[int, int] | Noner£   r¹   r¤   rC  r¥   úbool | None | DeprecatedArgrƒ   zCallable[..., Array])r¨   r9  r©   r@  rž   r?  rŸ   rC  r    r=  r¡   rD  r¢   rE  r£   r¹   r¤   rC  r¥   rF  rƒ   zCallable[..., Sequence[Array]])r¨   r9  r©   z)ResultMetadata | Sequence[ResultMetadata]rž   r?  rŸ   rC  r    r=  r¡   rD  r¢   rE  r£   r¹   r¤   rC  r¥   rF  rƒ   z&Callable[..., Array | Sequence[Array]])r!   údict[str, Any]rƒ   úSequence[tuple[str, Any]])r!   rH  rƒ   rG  )rµ   rA  rž   r?  )ry   r�   rk   r‚   r¨   r9  rž   r?  r    úSequence[Sequence[int]]r¡   rI  r¢   zSequence[tuple[int, int]]r£   r¹   r¤   rC  r¶   rH  rƒ   zSequence[ir.Value])rŸ   rC  rµ   zSequence[core.ShapedArray]r!   r   )UÚ
__future__r   Úcollections.abcr   r   r   r0   Údataclassesr,   r?   Útypingr   r   ÚnumpyrÌ   Újax._srcr	   r
   r   r   r   Újax._src.hashable_arrayr   Újax._src.interpretersr   r   r   Újax._src.layoutr   Újax._src.libr   r   Újax._src.lib.mlirr   Újax._src.typingr   r   r   r   r   Úsafe_maprr   Ú
unsafe_mapr¹   r<  r#   r(   r.   r<   rF   rN   rZ   r„   rŠ   rŽ   rB  r”   r™   r�   rª   r½   rÖ   rÎ   Ú	dataclassÚEffectrê   rõ   Úlowerable_effectsÚadd_typeÚcontrol_flow_allowed_effectsrø   rý   r   r  r7  Ú	Primitiver»   rÇ   Úsimple_implÚdef_effectful_abstract_evalÚprimitive_jvpsÚprimitive_transposesr-   Úprimitive_batchersÚregister_loweringrI   r$   r"   Ú<module>rd     s¯  ðõ #ç 7Ñ 7Û Û Û Û 	ß  ã å Ý Ý Ý Ý Ý 1Ý $Ý *Ý &Ý "Ý Ý #Ý  ÷$õ $ð —-‘- €€€ZØ˜C‘= 6Ñ)¨DÑ0Ð ð Øð	:Ø
ð:àð:ð ð:ð ð	:ð
 ð:ð 
ó:ð8 ðJØ
ðJà	ðJð ðJð 
ó	Jó	ò/óD-óOð
 :>ð
Ø
ð
Ø&6ð
ØBOó
ð  :>Ø8<Ø>BØ',ñRØðRð 7ðRð 6ð	Rð
 <ðRð !%ðRð ðRð !óRðp :>Ø8<Ø>BØ',ñ2Øð2ð 7ð2ð 6ð	2ð
 <ð2ð !%ð2ð ð2ð ó2ðj   $×"4Ñ"4Ñ4€óóð	/Ø'ð	/à'ð	/à,Eó	/ð 
ð
  Ø!Ø7:ØKNØ25Ø#&Ø(+Ù.;«oñØðà'ðð ð	ð
 ðð 5ðð Iðð 0ðð !ðð &ðð ,ðð òó 
ðð  
ð
  Ø!Ø7:ØKNØ25Ø#&Ø(+Ù.;«oñØðà1ðð ð	ð
 ðð 5ðð Iðð 0ðð !ðð &ðð ,ðð $òó 
ðð( "Ø"Ø7;ØKOØ26Ø#$Ø(,Ù.;«oñkØðkàBðkð ð	kð
 ðkð 5ðkð Iðkð 0ðkð !ðkð &ðkð ,ðkð ,ókóf ó$	÷Eñ Eð" €×Ñ˜dÔ#ô�—‘ó ó $ðñ
 ‹[€
Ø × Ñ × "Ñ " 9Ô -Ø × $Ñ $× -Ñ -¨iÔ 8ð	/à0ð	/ð ó	/òJòJðEØ	!ðEàðEð ðEð ð	Eð
 +ðEð ,ðEð 4ðEð !ðEð &ðEð *ðEð óEð,M-ð
 ðM-ð -ðM-ð óM-ð` ˆT�^‰^˜JÓ'€
Ø"€
Ô Ø €× Ñ �ZÔ  Ø 
× &Ñ &Ð'=Ô >Ø ,€× Ñ �*Ñ Ø&8€× Ñ ˜
Ñ #Ø*;¨)×*;Ñ*;Ø�zó+#€× Ñ ˜JÑ 'à €× Ñ �zÐ#4Õ 5r$   