
    UpfJ                     X   d dl T d dl mZ d dlmZ 	 ddlT d dlmZmZ	m
Z n# e$ rZ ed          edZ[ww xY wdd	lmZmZmZ  ej        ed
           G d de                      Z ej        ed
           G d de                      Z	 	 	 dddddeee                  fdZdS )   )*)_Dialect)constant   )get_op_result_or_valueget_op_results_or_values_cextz+Error loading imports from extension moduleN    )OptionalSequenceUnionT)replacec            	            e Zd ZdZ	 d	ddddeeeeee	         f                  f fdZ
ed             Zed             Zed             Z xZS )
ForOpz(Specialization for the SCF for op class.Nlocip	iter_argsc          	          |g }t          |          }d |D             }t                                          |||||||            | j        d         j        j        | j        d         j        g|R   dS )af  Creates an SCF `for` operation.

        - `lower_bound` is the value to use as lower bound of the loop.
        - `upper_bound` is the value to use as upper bound of the loop.
        - `step` is the value to use as loop step.
        - `iter_args` is a list of additional loop-carried arguments or an operation
          producing them as results.
        Nc                     g | ]	}|j         
S  )type).0args     X/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jaxlib/mlir/dialects/scf.py
<listcomp>z"ForOp.__init__.<locals>.<listcomp>1   s    11138111    r   r
   )_get_op_results_or_valuessuper__init__regionsblocksappendoperandsr   )	selflower_boundupper_boundstepr   r   r   results	__class__s	           r   r    zForOp.__init__   s    $ I-i88	11y111[+tYCB 	 	
 	
 	
 	&Q%dmA&6&;FgFFFFFFr   c                 2    | j         d         j        d         S )z%Returns the body (block) of the loop.r
   r!   r"   r%   s    r   bodyz
ForOp.body7        |A%a((r   c                 &    | j         j        d         S )z+Returns the induction variable of the loop.r
   r.   	argumentsr-   s    r   induction_variablezForOp.induction_variable<   s     y"1%%r   c                 *    | j         j        dd         S )zReturns the loop-carried arguments usable within the loop.

        To obtain the loop-carried operands, use `iter_args`.
        r   Nr1   r-   s    r   inner_iter_argszForOp.inner_iter_argsA   s     y"122&&r   N)__name__
__module____qualname____doc__r   r   	OperationOpViewr   Valuer    propertyr.   r3   r5   __classcell__r*   s   @r   r   r      s        22 JNG G G G
 E)VXe_"DEFG G G G G G8 ) ) X) & & X& ' ' X' ' ' ' 'r   r   c                   Z     e Zd ZdZddddd fdZed             Zed             Z xZS )	IfOpz'Specialization for the SCF if op class.NF)hasElser   r   c                    |g }g }|                     |           g }|                    |           t                                          ||            | j        d         j        j         g   |r | j        d         j        j         g   dS dS )zCreates an SCF `if` operation.

        - `cond` is a MLIR value of 'i1' type to determine which regions of code will be executed.
        - `hasElse` determines whether the if operation has the else branch.
        Nr
   r   )r#   extendr   r    r!   r"   )	r%   condresults_rC   r   r   r$   r)   r*   s	           r   r    zIfOp.__init__N   s     Hx   $'''%Q%r** 	/)DLO")2....	/ 	/r   c                 2    | j         d         j        d         S )z+Returns the then block of the if operation.r
   r,   r-   s    r   
then_blockzIfOp.then_block_   r/   r   c                 2    | j         d         j        d         S )z+Returns the else block of the if operation.r   r
   r,   r-   s    r   
else_blockzIfOp.else_blockd   r/   r   r6   )	r7   r8   r9   r:   r    r>   rI   rK   r?   r@   s   @r   rB   rB   J   s        11/u$4 / / / / / / /" ) ) X) ) ) X) ) ) ) )r   rB   r   r   c             #     K   |d}|| }d} | ||g}t          |          D ]o\  }}t          |t                    r(t          t                                          |          }n(t          |t                    rt          d|d          |||<   p|\  } }}t          | |||||          }	|	j	        }
t          |	j                  }t          |	j                  5  t          |          dk    r|
||	j        fV  n0t          |          dk    r|
|d         |	j        d         fV  n|
V  d d d            d S # 1 swxY w Y   d S )Nr   r
   zp=z must be int.r   )	enumerate
isinstanceintr   	IndexTypegetfloat
ValueErrorr   r3   tupler5   InsertionPointr.   lenr)   )startstopr(   r   r   r   paramsipfor_opivs              r   for_r^   j   s      ||T4 F&!!  1a 	3!,,AA5!! 	31111222q		E45$iSR@@@F		"Bf,--I		$	$  y>>Ai/////^^q  ilFN1$555555HHH                 s   AD99D= D=)NNN)_scf_ops_genr   arithr   ir_ods_commonr   _get_op_result_or_valuer   r   r	   	_ods_cextImportErroreRuntimeErrortypingr   r   r   register_operationr   rB   r=   r^   r   r   r   <module>rj      s       " " " " " "      M          
  M M M
,D
E
E1LM - , , , , , , , , , h555/' /' /' /' /'E /' /' 65/'d h555) ) ) ) )4 ) ) 65)B 
	+/	! 	! ! ! (	! ! ! ! ! !s   ! 727