
    J/Ph                       d dl Z d dlZd dlmZmZmZmZ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mZmZmZmZ d dlmZ d dlmZmZ d dlZd dlmZ d dl Z dZ!d Z"e j#        gZ$i Z%g dZ&d	d
gZ'g dZ(g dZ)g dZ*e'e(z   e)z   e*z   ddgz   Z+ed             Z,d Z-ed             Z. G d de/          Z0 G d de0          Z1 G d de1          Z2 G d de/          Z3 G d de/          Z4 e5ej6        j7        8                                          ej9        gz   Z:ej;        j7        8                                Z<ej=        j7        8                                Z>d ej?        D             Z@dS )    N)typesirconfigcgutilserrors)mk_unique_varfind_topo_orderdprint_func_irget_global_func_typguardrequireget_definitionfind_callnamefind_build_sequence
find_constis_namedtuple_classbuild_definitionsfind_potential_aliasesget_canonical_aliasGuardException)compute_cfg_from_blocks)npydecl	signature)	intrinsic)emptyzerosonesfullrandrandn)ranfrandom_samplesamplerandomstandard_normal)	chisquareweibullpower	geometricexponentialpoissonrayleigh)normaluniformbetabinomialfgamma	lognormallaplacerandint
triangularc                 d   t          t          |t          j        j                             t          t          |t          j        j                             |j        rt          j        nt          j        |j        rt          j        nt          j        fd}t          ||          |fS )a  
    Calculate index value "idx" relative to a size "size" value as
    (idx % size), where "size" is known to be positive.
    Note that we use the mod(%) operation here instead of
    (idx < 0 ? idx + size : idx) because we may have situations
    where idx > size due to the way indices are calculated
    during slice/range analysis.

    Both idx and size have to be Integer types.
    size should be from the array size vars that array_analysis
    adds and the bitwidth should match the platform maximum.
    c                    |                                }|                                }j        r|                    |d         |          }n|                    |d         |          }j        r|                    |d         |          }n|                    |d         |          }|                    |          }t
          j                            |d          }	|                    d||	          }
|                    d||          }|                    d||          }|	                    |||          }|	                    ||	|
                    ||                    }|	                    |
||          }|S )Nr      <z>=z<=)get_data_typesignedsextzextnegllvmliter   Constanticmp_signedselectadd)contextbuildersigargsll_idx_unified_tyll_unified_tyidxsizeneg_sizezeroidx_negativepos_oversizeneg_oversizepos_resneg_resmodidx_unified
unified_tys                   \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/parfors/array_analysis.pycodegenzwrap_index.<locals>.codegenf   sc   #11+>>--j99 	;,,tAw(9::CC,,tAw(9::C 	8<<Q77DD<<Q77D;;t$${##M155 **3T::**4d;;**4h??..tS99..tW[[d5K5KLLnn\7G<<
    )	r   
isinstancer   scalarsIntegerr=   intpuintpr   )	typingctxrL   rM   rY   rV   rW   s       @@rX   
wrap_indexra   Q   s     JsEM122333JtU]233444  ${;J #
;%**K     0 Zd++W44rZ   c                 >    | dk     r| | k    rdS | |z   S | |k    r|S | S Nr    )rL   rM   s     rX   wrap_index_literalre      s8    
Qww4%<<1:$;;KJrZ   c                    t          |          dk    rt          j        |          f}t          |d                   dk    sJ t          d |d         dd         D                       sJ t	          |d         d         t          j                  st          j        d          d }t          t          j	        g|R  |fS )z
    A function that asserts the inputs are of equivalent size,
    and throws runtime error when they are not. The input is
    a vararg that contains an error message, followed by a set
    of objects of either array, tuple or integer.
    r:   r   c              3      K   | ]@}t          |t          j        t          j        t          j        t          j        f          V  Ad S N)r[   r   ArrayCompatible	BaseTuple	SliceTyper]   ).0as     rX   	<genexpr>zassert_equiv.<locals>.<genexpr>   s^          	1!OOM	
 	 	     rZ   Nz&first argument must be a StringLiteralc           	         	
 t          |          dk    sJ t          j        |d                   }|j        d         }|j        d         d         j        	 fd
 	
fd}t          dt          |          dz
            D ].} |||         ||         ||dz            ||dz                       /                     t          j        d           }|S )Nr:   r   c                    t          |t          j                  r:                     |          |           }t	          j        |j                  S t          |t          j                  rt	          j        |           S | gS rh   )r[   r   ri   
make_arrayr   unpack_tupleshaperj   )rm   atyaryrG   rF   s      rX   unpack_shapesz4assert_equiv.<locals>.codegen.<locals>.unpack_shapes   s|    #u455 -g((--gwBB+GSY???C11 +GQ777s
rZ   c                     | |          } ||          }t          |          t          |          k    sJ t          ||          D ]\  }}                    d||          }                    |          5 \  }	}
|	5  	 d d d            n# 1 swxY w Y   |
5  j                            t          f           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )Nz==)lenzipicmp_unsignedif_else	call_convreturn_user_excAssertionError)rm   rt   bbtyashapesbshapesmnm_eq_nthenorelserG   rF   msgrv   s              rX   pairwisez/assert_equiv.<locals>.codegen.<locals>.pairwise   s   #mAs++G#mAs++Gw<<3w<<////gw//  A ..tQ::__V,, v                  )99#^cV                               sZ   =C$BC$BC$BC$#CC$CC$CC$$C(	+C(	)	rx   r   rr   rI   literal_valuerangeget_constant_genericr   NoneType)rF   rG   rH   rI   tuptup_typer   irr   rv   s   ``       @@rX   rY   zassert_equiv.<locals>.codegen   s	   4yyA~~~~"7DG448A;hqk!n*	 	 	 	 	 		 	 	 	 	 	 	 	 q#h--!+,, 	G 	GAHSVXa[#a!e*hq1uoFFFF((%.$GGrZ   )
rx   r   StarArgTupleallr[   StringLiteralr   TypingErrorr   none)r`   valrY   s      rX   assert_equivr      s     3xx!|| !#&&(s1v;;????   Q        c!fQi!455 K !IJJJ     D UZ&#&&&//rZ   c                   b    e Zd ZdZddZd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd ZdS )EquivSetzPEquivSet keeps track of equivalence relations between
    a set of objects.
    Nr   c                 @    |r|ni | _         |r|ni | _        || _        dS )zdCreate a new EquivSet object. Optional keyword arguments are for
        internal use only.
        N)
obj_to_ind
ind_to_objnext_ind)selfr   r   r   s       rX   __init__zEquivSet.__init__   s1     )3:**(2:** !rZ   c                     t                      S )z)Return an empty EquivSet object.
        )r   r   s    rX   r   zEquivSet.empty   s     zzrZ   c                     t          t          j        | j                  t          j        | j                  | j                  S )Return a new copy.
        )r   r   next_id)r   copydeepcopyr   r   r   r   s    rX   clonezEquivSet.clone   s>     }T_55}T_55M
 
 
 	
rZ   c                 6    d                     | j                  S )NzEquivSet({}))formatr   r   s    rX   __repr__zEquivSet.__repr__   s    $$T_555rZ   c                     | j         i k    S )z=Return true if the set is empty, or false otherwise.
        )r   r   s    rX   is_emptyzEquivSet.is_empty   s     "$$rZ   c                 8    | j                             |d          S )zkReturn the internal index (greater or equal to 0) of the given
        object, or -1 if not found.
        r   )r   get)r   xs     rX   _get_indzEquivSet._get_ind   s     ""1b)))rZ   c                 b    || j         v r| j         |         }n| j        }| xj        dz  c_        |S )zyReturn the internal index (greater or equal to 0) of the given
        object, or create a new one if not found.
        r:   )r   r   )r   r   r   s      rX   _get_or_add_indzEquivSet._get_or_add_ind   s;     "AAAMMQMMrZ   c                     t          |          dk    sJ t           fd|D                       }t          |          }t          j        dk    rt          d||           | j        vr
g  j        |<   t          ||          D ]\  }}||k    r:| j        |         vr* j        |                             |           | j	        |<   E| j        v rC j        |         D ],}| j	        |<    j        |                             |           - j        |= | j	        |<    j        |                             |           dS )zXBase method that inserts a set of equivalent objects by modifying
        self.
        r:   c              3   B   K   | ]}                     |          V  d S rh   )r   rl   r   r   s     rX   rn   z#EquivSet._insert.<locals>.<genexpr>  s1      ;;T))!,,;;;;;;rZ      z_insert:N)
rx   tupleminr   DEBUG_ARRAY_OPTprintr   ry   appendr   )r   objsindsindr   objr   s   `      rX   _insertzEquivSet._insert
  sl    4yy1}}}};;;;d;;;;;$ii!Q&&*dD)))t&&#%DOC $oo 	5 	5FAsCxxts333OC(//444+.DOC(''!_Q/ 7 7-0*,33A6666** ,/DOC(OC(//4444	5 	5rZ   c                       fdD             }t          |          dk    rt          fd|D                       S t          fdD                       S )zfTry to derive if given objects are equivalent, return true
        if so, or false otherwise.
        c                 :    g | ]}                     |          S rd   r   r   s     rX   
<listcomp>z%EquivSet.is_equiv.<locals>.<listcomp>.  s%    ///Qa  ///rZ   r   c              3   $   K   | ]
}|k    V  d S rh   rd   )rl   r   r   s     rX   rn   z$EquivSet.is_equiv.<locals>.<genexpr>1  s'      ..AqCx......rZ   c                 (    g | ]}|d          k    S )r   rd   )rl   r   r   s     rX   r   z%EquivSet.is_equiv.<locals>.<listcomp>3  s!    333T!W333rZ   )maxr   )r   r   r   r   s   `` @rX   is_equivzEquivSet.is_equiv*  sz     0///$///$ii"99..........3333d333444rZ   c                     |                      |          }|dk    r+| j        |         }|D ]}t          |t                    r|c S dS )zvCheck if obj is equivalent to some int constant, and return
        the constant if found, or None otherwise.
        r   N)r   r   r[   int)r   r   r   r   r   s        rX   get_equiv_constzEquivSet.get_equiv_const5  s^     mmC  !88?3'D  a%% HHHtrZ   c                     |                      |          }|dk    rt          | j        |                   S t                      S ).Return the set of equivalent objects.
        r   )r   setr   )r   r   r   s      rX   get_equiv_setzEquivSet.get_equiv_setA  s<     mmC  !88ts+,,,uurZ   c                 ,    |                      |          S )zInsert a set of equivalent objects by modifying self. This
        method can be overloaded to transform object type before insertion.
        )r   )r   r   s     rX   insert_equivzEquivSet.insert_equivI  s     ||D!!!rZ   c                                                       } j        |_        |j                                        D ]}t	           fd|D                       }i }t          ||          D ]1\  }}||v r||                             |           %|dk    r|g||<   2|                                D ]*}t          |          dk    r|                    |           +|S )z Return the intersection of self and the given equiv_set,
        without modifying either of them. The result will also keep
        old equivalence indices unchanged.
        c              3   B   K   | ]}                     |          V  d S rh   r   r   s     rX   rn   z%EquivSet.intersect.<locals>.<genexpr>X  s/      88aq))888888rZ   r   r:   )	r   r   r   valuesr   ry   r   rx   r   )	r   	equiv_setnew_setr   r   r   r   r   vs	   `        rX   	intersectzEquivSet.intersectO  s    
 **,,=(//11 	' 	'D8888488888DJD$ ( (1
??qM((++++!VV%&CJqM&&(( ' 'q66A::OOA&&&' rZ   )NNr   )__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r   r   r   rd   rZ   rX   r   r      s         ! ! ! !  

 
 
6 6 6% % %
* * *	 	 	5 5 5@	5 	5 	5
 
 
  " " "    rZ   r   c                        e Zd ZdZ	 	 	 	 	 	 d fd	Zd Zd Zd Zd Z fd	Z	 fd
Z
d Z fdZ fdZ fdZd Zd Zd Zd Z fdZd Zd Z xZS )ShapeEquivSetad  Just like EquivSet, except that it accepts only numba IR variables
    and constants as objects, guided by their types. Arrays are considered
    equivalent as long as their shapes are equivalent. Scalars are
    equivalent only when they are equal in value. Tuples are equivalent
    when they are of the same size, and their elements are equivalent.
    Nr   c                     || _         |r|ni | _        |r|ni | _        |r|ni | _        t	          t
          |                               |||           dS )zCreate a new ShapeEquivSet object, where typemap is a dictionary
        that maps variable names to their types, and it will not be modified.
        Optional keyword arguments are for internal use only.
        N)typemapdefs
ind_to_varind_to_constsuperr   r   )	r   r   r   r   r   r   r   r   	__class__s	           rX   r   zShapeEquivSet.__init__q  si      !(DDb	 )3:**,8@LLbmT""++J
GLLLLLrZ   c                 ,    t          | j        i           S )z'Return an empty ShapeEquivSet.
        )r   r   r   s    rX   r   zShapeEquivSet.empty  s     T\2...rZ   c                 (   t          | j        t          j        | j                  t          j        | j                  t          j        | j                  t          j        | j                  | j        t          j        | j	                            S )r   )r   r   r   r   r   r   )
r   r   r   r   r   r   r   r   r   ind_toconstr   s    rX   r   zShapeEquivSet.clone  sq     L49%%y11}T_55}T_55Mt'788
 
 
 	
rZ   c                 N    d                     | j        | j        | j                  S )Nz1ShapeEquivSet({}, ind_to_var={}, ind_to_const={}))r   r   r   r   r   s    rX   r   zShapeEquivSet.__repr__  s(    BIIOT_d.?
 
 	
rZ   c                 l    t          |t          j                  st          |t                    rt          |t                    r|n|j         j        vrfS  j                 }t          |t          j        t          j        f          rat          |t          j                  r|j	        nt          |          }|dk    rfS t          fdt          |          D                       S fS t          |t          j                  r)t          |j        t                    r|j        S |j        fS t          |t                    r  fdt          fd|D                       S t          |t                    r|fS t           j        dk    r t%          dt'          |           d           dS )	zReturn a set of names for the given obj, where array and tuples
        are broken down to their individual shapes or elements. This is
        safe because both Numba array shapes and Python tuples are immutable.
        r   c              3   D   K   | ]}d                      |          V  dS )z{}#{}N)r   )rl   r   names     rX   rn   z+ShapeEquivSet._get_names.<locals>.<genexpr>  s1       N NQa!8!8 N N N N N NrZ   c                 h                         |           }t          |          dk    r|d         S |S rc   )
_get_namesrx   )r   namesr   s     rX   	get_namesz+ShapeEquivSet._get_names.<locals>.get_names  s1    **u::?? 8OrZ   c              3   .   K   | ]} |          V  d S rh   rd   )rl   r   r   s     rX   rn   z+ShapeEquivSet._get_names.<locals>.<genexpr>  s+      33!1333333rZ   r:   zIgnoring untracked object type z in ShapeEquivSetrd   )r[   r   Varstrr   r   r   rj   ri   ndimrx   r   r   Constvaluer   r   r   r   type)r   r   typr   r   r   s   `   @@rX   r   zShapeEquivSet._get_names  s   
 c26""  	jc&:&:  	$S#..<33CHD4<''w,t$C#1FGHH 
%c5+@AA& XX  199 7N  N N N N%++ N N NNNNwRX&& 	#)U++ $y 	|#U## 
	     3333s333333S!! 	6M!Q&&N$s))NNNP P PrrZ   c                     t          |          dk    sJ  fd|D             }d |D             }t          |          dk    rdS d |D             }|d         t          fd|D                       s4t          j        dk    r"t	          d                    |                     dS t                    D ]0fd	|D             } t          t                     j	        | s dS 1d
S )zWOverload EquivSet.is_equiv to handle Numba IR variables and
        constants.
        r:   c                 :    g | ]}                     |          S rd   r   r   s     rX   r   z*ShapeEquivSet.is_equiv.<locals>.<listcomp>  %    666AT__Q''666rZ   c                     g | ]
}|d k    |S rd   rd   rl   r   s     rX   r   z*ShapeEquivSet.is_equiv.<locals>.<listcomp>      5551Q"WWQWWWrZ   Fc                 ,    g | ]}t          |          S rd   rx   )rl   r   s     rX   r   z*ShapeEquivSet.is_equiv.<locals>.<listcomp>  s    333U333rZ   r   c              3   $   K   | ]
}|k    V  d S rh   rd   rl   r   r   s     rX   rn   z)ShapeEquivSet.is_equiv.<locals>.<genexpr>  s'      ,,419,,,,,,rZ   z#is_equiv: Dimension mismatch for {}c                      g | ]
}|         S rd   rd   rl   obj_namer   s     rX   r   z*ShapeEquivSet.is_equiv.<locals>.<listcomp>      ;;;XXa[;;;rZ   T)
rx   r   r   r   r   r   r   r   r   r   )r   r   	obj_namesndimsr   r   r   r   s   `    @@rX   r   zShapeEquivSet.is_equiv  s)    4yy1}}}}6666666	55	555	y>>Q533333Qx,,,,e,,,,, 	%**;BB4HHIII5t 	 	A;;;;;;;E65--6> uutrZ   c                     |                      |          }t          |          dk    rdS t          t          |                               |d                   S )ztIf the given object is equivalent to a constant scalar,
        return the scalar value, or None otherwise.
        r:   Nr   )r   rx   r   r   r   r   r   r   r   s      rX   r   zShapeEquivSet.get_equiv_const  sL     $$u::??4]D))99%(CCCrZ   c                     |                      |          }t          |          dk    rdS |                     |d                   }| j                            |g           }|g k    r|d         ndS )ztIf the given object is equivalent to some defined variable,
        return the variable, or None otherwise.
        r:   Nr   )r   rx   r   r   r   )r   r   r   r   vss        rX   get_equiv_varzShapeEquivSet.get_equiv_var  sk     $$u::??4mmE!H%%_  b))br!uud*rZ   c                     |                      |          }t          |          dk    rdS t          t          |                               |d                   S )r   r:   Nr   )r   rx   r   r   r   r  s      rX   r   zShapeEquivSet.get_equiv_set  sL     $$u::??4]D))77aAAArZ   c                 r   g }|D ]+}|| j         v r |                    | j         |                    ,g }d}t                      }t          |          D ]m}|| j        v rH| j        |         D ]:}|j        |vr/|                    |           |                    |j                   ;|| j        v r|J | j        |         }nt          t          |           
                    |           | j         |d                  }	t          |          D ]}|| j        v r| j        |= || j        |	<   ||| j        |	<   dS dS )zCOverload EquivSet._insert to manage ind_to_var dictionary.
        Nr   )r   r   r   sortedr   r   rE   r   r   r   r   )r   r   r   r   varlistconstvalr   r   r   new_indr   s             rX   r   zShapeEquivSet._insert   sm     	2 	2Cdo%%DOC0111 	0 	0ADO##+ * *AFeOOq)))		!&)))D%%%''',Q/mT""**4000/$q'*T 	' 	'ADO##OA&#* )1Dg&&&  rZ   c                     t          |          dk    sJ  fd|D             }d |D             }t          |          dk    rdS t          d |D             g           }d |D             }|d         t          fd|D                       sJ d	                    |                      g }g }|D ]}t	          |t
                    s|f}|D ]}t	          |t          j                  rC|j        |vr:|j         j	        v r|
                    d|           n|                    |           t	          |t          j                  r#|j        |vr|                    |j                   |D ]U}|j        }	|	|v rH|	 j        vr?|	g j         j        <    j         j        |	<   |g j         j        <    xj        dz  c_        V|D ]M}
|
|v rG|
 j        vr>|
g j         j        <    j         j        |
<   |
 j         j        <    xj        dz  c_        Nd
}t'                    D ]1fd|D             } t)          t*                     j        | }|p|}2|S )zOverload EquivSet.insert_equiv to handle Numba IR variables and
        constants. Input objs are either variable or constant, and at least
        one of them must be variable.
        r:   c                 :    g | ]}                     |          S rd   r   r   s     rX   r   z.ShapeEquivSet.insert_equiv.<locals>.<listcomp>"  r   rZ   c                     g | ]
}|d k    |S r   rd   r   s     rX   r   z.ShapeEquivSet.insert_equiv.<locals>.<listcomp>#  r  rZ   Nc                 ,    g | ]}t          |          S rd   )listr   s     rX   r   z.ShapeEquivSet.insert_equiv.<locals>.<listcomp>&  s    000T!WW000rZ   c                 ,    g | ]}t          |          S rd   r  r   s     rX   r   z.ShapeEquivSet.insert_equiv.<locals>.<listcomp>'  s    +++AQ+++rZ   r   c              3   $   K   | ]
}|k    V  d S rh   rd   r  s     rX   rn   z-ShapeEquivSet.insert_equiv.<locals>.<genexpr>)  s8       
 
DAI
 
 
 
 
 
rZ   zDimension mismatch for {}Fc                      g | ]
}|         S rd   rd   r  s     rX   r   z.ShapeEquivSet.insert_equiv.<locals>.<listcomp>O  r	  rZ   )rx   sumr   r   r[   r   r   r   r   r   insertr   r   r   r   r   r   r   r   r   r   r   r   )r   r   r
  r   r  r  	constlistr   varr   constsome_changeie_resr   r   r   s   `            @@rX   r   zShapeEquivSet.insert_equiv  s   
 4yy1}}}}6666666	55	555	y>>QF00i000"55+++++Qx 
 
 
 
$
 
 
 
 
 	4 	4&--d33	4 	4 	4 	 	0 	0Cc5)) f 0 0c26** ,CH4G4Gx49,,q#....s+++c28,, 0ci96L6L$$SY///0  	# 	#C8Du}}ddo&=&=26.(,%25."  	# 	#E~~u'?'?27.)-&38!$-0"t 	0 	0A;;;;;;;E<U=$//<eDF%/KKrZ   c                 0    |                      |          duS )zEReturn true if the shape of the given variable is available.
        N	get_shaper   r   s     rX   	has_shapezShapeEquivSet.has_shapeU  s     ~~d##4//rZ   c                 ,    t          | j        |          S )ztReturn a tuple of variables that corresponds to the shape
        of the given array, or None if not found.
        )r   
_get_shaper)  s     rX   r(  zShapeEquivSet.get_shapeZ  s     T_d+++rZ   c                 x   |                      |          }t          |dk               g }|D ]}t          || j        v            | j        |         }|g k    r|                    |d                    Gt          || j        v            | j        |         }|                    |           t          |          S )zReturn a tuple of variables that corresponds to the shape
        of the given array, or raise GuardException if not found.
        rd   r   )get_shape_classesr   r   r   r   r   )r   r   r   rs   r   r  s         rX   r,  zShapeEquivSet._get_shape`  s     %%d++
 	! 	!AA()))#BRxxRU####T..///&q)R    U||rZ   c                     t          |t          j                  r|j        }| j        v r j        |         nd}t          |t
          j        t
          j        t
          j        f          sg S t          |t
          j                  r|j	        dk    rg S  
                    |          }t           fd|D                       }|S )zInstead of the shape tuple, return tuple of int, where
        each int is the corresponding class index of the size object.
        Unknown shapes are given class index -1. Return empty tuple
        if the input name is a scalar variable.
        Nr   c              3   B   K   | ]}                     |          V  d S rh   r   )rl   r   r   s     rX   rn   z2ShapeEquivSet.get_shape_classes.<locals>.<genexpr>  s/      ;;TT]]4((;;;;;;rZ   )r[   r   r   r   r   r   rj   rk   ri   r   r   r   )r   r   r   r   r   s   `    rX   r.  zShapeEquivSet.get_shape_classesr  s     dBF## 	9D$(DL$8$8dl4  ds%2G  	
 Ic5011 	ch!mmI%%;;;;U;;;;;rZ   c                    t          t          |                               |          }i }|j                                        D ]\  }}t          |          dk    sJ |d         }|| j        v sJ ||j        v sJ | j        |         }|j        |         }|| j        v sJ ||j        v sJ g }	d |j        |         D             }
| j        |         D ] }|j        |
v r|		                    |           !|	||<   ||_        |S )z<Overload the intersect method to handle ind_to_var.
        r   c                     g | ]	}|j         
S rd   r   r   s     rX   r   z+ShapeEquivSet.intersect.<locals>.<listcomp>  s    ===QV===rZ   )
r   r   r   r   itemsrx   r   r   r   r   )r   r   newsetr   r   r   r   jkr  r   r   r   s               rX   r   zShapeEquivSet.intersect  s8    }d++55i@@
(..00 	$ 	$GAtt99q====q'C$/))))).....$A$S)A''''	,,,,,G==Y%9!%<===E_Q' & &6U??NN1%%%#JqMM&rZ   c                    t          |t          j                  r|j        }|| j        v r5| j        |xx         dz  cc<   t          |                     |                    }|D ]}|| j        v r|                    |           | j        |         }| j        |= | j	        |         
                    |           | j	        |         g k    r| j	        |= || j        v sJ d | j        |         D             }||v re|                    |          }| j        |         |= | j        |         g k    r1| j        |= || j	        v r | j	        |         D ]
}| j        |= | j	        |= dS d| j        |<   dS )a  Increment the internal count of how many times a variable is being
        defined. Most variables in Numba IR are SSA, i.e., defined only once,
        but not all of them. When a variable is being re-defined, it must
        be removed from the equivalence relation and added to the redefined
        set but only if that redefinition is not known to have the same
        equivalence classes. Those variables redefined are removed from all
        the blocks' equivalence sets later.

        Arrays passed to define() use their whole name but these do not
        appear in the equivalence sets since they are stored there per
        dimension. Calling _get_names() here converts array names to
        dimensional names.

        This function would previously invalidate if there were any multiple
        definitions of a variable.  However, we realized that this behavior
        is overly restrictive.  You need only invalidate on multiple
        definitions if they are not known to be equivalent. So, the
        equivalence insertion functions now return True if some change was
        made (meaning the definition was not equivalent) and False
        otherwise. If no change was made, then define() need not be
        called. For no change to have been made, the variable must
        already be present. If the new definition of the var has the
        case where lhs and rhs are in the same equivalence class then
        again, no change will be made and define() need not be called
        or the variable invalidated.
        r:   c                     g | ]	}|j         
S rd   r3  r   s     rX   r   z(ShapeEquivSet.define.<locals>.<listcomp>  s    @@@QV@@@rZ   N)r[   r   r   r   r   r  r   r   rE   r   remover   index)	r   r   	redefinedname_resone_namer   r   r6  r   s	            rX   definezShapeEquivSet.define  s   6 dBF## 	9D49IdOOOq OOODOOD1122H$ 7 7 t..MM    1A1OA&--h777q)R// OA.////@@T_Q-?@@@Eu}}!KK-- OA.q1?1-33 $ 2 DO33+/?1+= != !=C(,(<(<$(OA$617 74  DIdOOOrZ   c                 r    |                                 D ]!\  }}|dk    r|                     ||           "dS )zUnion with the given defs dictionary. This is meant to handle
        branch join-point, where a variable may have been defined in more
        than one branches.
        r   N)r4  r?  )r   r   r<  r7  r   s        rX   
union_defszShapeEquivSet.union_defs  sG    
 JJLL 	* 	*DAq1uuAy)))	* 	*rZ   )NNNNr   N)r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r*  r(  r,  r.  r   r?  rA  __classcell__r   s   @rX   r   r   h  s         M M M M M M8/ / /

 
 

 
 

) ) )V    *D D D D D	+ 	+ 	+B B B B B2 2 2 2 287 7 7 7 7r0 0 0
, , ,  $  ,    .:  :  : x* * * * * * *rZ   r   c                   ~     e Zd ZdZ	 	 	 	 	 	 	 	 d fd	Zd Zd Zd Zd Zd fd		Z	d fd
	Z
 fdZd Z fdZ xZS )SymbolicEquivSeta/  Just like ShapeEquivSet, except that it also reasons about variable
    equivalence symbolically by using their arithmetic definitions.
    The goal is to automatically derive the equivalence of array ranges
    (slicing). For instance, a[1:m] and a[0:m-1] shall be considered
    size-equivalence.
    Nr   c
                     |r|ni | _         |r|ni | _        |r|ni | _        i | _        i | _        t          t          |                               ||||||	           dS )zCreate a new SymbolicEquivSet object, where typemap is a dictionary
        that maps variable names to their types, and it will not be modified.
        Optional keyword arguments are for internal use only.
        N)def_byref_by
ext_shapesrel_mapwrap_mapr   rE  r   )r   r   rG  rH  rI  r   r   r   r   r   r   s             rX   r   zSymbolicEquivSet.__init__  s    & !'.ffB
 !'.ffB )3:**
  %%..T:z:w	
 	
 	
 	
 	
rZ   c                 *    t          | j                  S )z*Return an empty SymbolicEquivSet.
        )rE  r   r   s    rX   r   zSymbolicEquivSet.empty  s      ---rZ   c                 f    d                     | j        | j        | j        | j        | j                  S )NzHSymbolicEquivSet({}, ind_to_var={}, def_by={}, ref_by={}, ext_shapes={}))r   r   r   rG  rH  rI  r   s    rX   r   zSymbolicEquivSet.__repr__   s4    ((.) )		
rZ   c                    t          | j        t          j        | j                  t          j        | j                  t          j        | j                  t          j        | j                  t          j        | j                  t          j        | j	                  t          j        | j
                  | j        	  	        S )r   )rG  rH  rI  r   r   r   r   r   )rE  r   r   rG  rH  rI  r   r   r   r   r   r   r   s    rX   r   zSymbolicEquivSet.clone,  s      L9T[))9T[))y1149%%y11}T_55}T_55M

 

 

 
	
rZ   c                 ,    t          | j        |          S )zjRetrieve a definition pair for the given variable,
        or return None if it is not available.
        )r   _get_or_set_relr)  s     rX   get_relzSymbolicEquivSet.get_rel;  s     T)4000rZ   c                     t          |t          j                  r|j        }t	           j                            |d          dk               | j        v r j        |         S t	          |du           d fdt          ||          }|df}t          |t          j	                  rE|j
        dk    rt          || j                  \  }}|dk    r|d	k    rt           fd
|j        D                       }d|v rdS  j                            |g           }|                    |           t#          |          dk    r                     |           | j        |<   n|j
        dk    r                     |j        |          }	                     |j        |          }
|	|
dS |j        t.          j        k    r |	|
          }n]|j        t.          j        k    r |	|
          }n;t          |t          j                  r!t          |j        t8                    r|j        }t	          |du           | j        |<   t          |t8                    s-t          |t                    r|d         |k    s|d         dk    rt          |t                    r|\  }| j        vr
g  j        |<    j        |                             | f                                |          }|dk    rt j        |         }g }|D ]'}| j        v r|fd j        |         D             z  }(t#          |          dk    r(tA          tB                                         |           |S )zRetrieve a definition pair for the given variable,
        and if it is not already available, try to look it up
        in the given func_ir, and remember it for future use.
        r   r:   Nc                     t          | t                    }t          |t                    }|r|r| |z   S |\  }}|| |z   fS | \  }}|r|||z   fS d S rh   r[   r   )r   y
x_is_const
y_is_constr"  offsets         rX   plusz.SymbolicEquivSet._get_or_set_rel.<locals>.plusN  sv    '3//
'3//
 $! 1 1u()f #QZ00$%MS&! $ #QZ00#trZ   c                     t          |t                    r | |           S t          | t                    r?t          |t                    r*| d         |d         k    r | d         |d                   S d S Nr   r:   )r[   r   r   )r   rU  minusrY  s     rX   r\  z/SymbolicEquivSet._get_or_set_rel.<locals>.minus^  s}    a%% 	 4A2;;&q%(( "1e,,  !! 51qt,,,4rZ   callr   ra   znumba.parfors.array_analysisc              3   X   K   | ]$}j                             |j        d           V  %dS )r   N)r   r   r   r   s     rX   rn   z3SymbolicEquivSet._get_or_set_rel.<locals>.<genexpr>u  sH       & &@ADO//;;& & & & & &rZ   r   binopc                 (    g | ]\  }}| k    |S rd   rd   )rl   r   r   rX  s      rX   r   z4SymbolicEquivSet._get_or_set_rel.<locals>.<listcomp>  s0     *" *" *"(.A'(VG|| %&'3||rZ   )"r[   r   r   r   r   r   r   rG  r   Expropr   r   r   rI   rI  r   rx   r   rP  lhsrhsfnoperatorrE   subr   r   r   rH  r   r   r   rE  )r   r   func_irexprr   fnamemod_namer;  r   rd  re  r"  r   r   r   r\  rX  rY  r   s   `              @@@rX   rP  z SymbolicEquivSet._get_or_set_relA  s   
 dBF## 	9D	dA&&!+,,,4;;t$$G4'((($ $ $ 
  
  
  
  
  
  "'400D1IE$(( $#7f$$&3t|' ' 'OE8 --$(FFF % & & & &EIY& & & ! ! ;;#'4 $ 3 3E2 > >T***u::>> LL///16.W''..txAAC..txAAC {ck#tHL00 $S#HL00 %c3D"(++ #
4:s0K0K #
E%&&& %DK%%% I5%((I1X%%qQ eU++ I$)MS&4;..+-C(K$++TF7O<<<--,,Caxx#s3 "#' " "C"dk11 % *" *" *" *"26+c2B*" *" *" !"
 u::>>!"2D99AA%HHHLrZ   c                    t          |t          j                  r|j        }n|}t	          t
          |                               ||           |r| j                            |d          dk    rt          |t          j
                  rt          | j        ||          }t          |t                    r|                     ||g           t          |t          j                  rh|                     |          }|| j        vr|g| j        |<   || j        |<   || j        v r!| j        |                             |           n|g| j        |<   dS dS dS dS )af  Besides incrementing the definition count of the given variable
        name, it will also retrieve and simplify its definition from func_ir,
        and remember the result for later equivalence comparison. Supported
        operations are:
          1. arithmetic plus and minus with constants
          2. wrap_index (relative to some given size)
        r   r:   TN)r[   r   r   r   r   rE  r?  r   r   r   Numberr   rP  r   r   r   r   r   r   r   )	r   r"  r<  ri  r   r   r   r   r   s	           rX   r?  zSymbolicEquivSet.define  s_    c26"" 	8DDD%%,,T9===		dA&&!++3-- , $.g>>E%%% ,dE]+++#rv&& 1**400t..,06DOC(,/DOD)$/))OC(//4444,/5DOC(4%	 	++++rZ   c                    t                      }t                      }|D ]a}|                     |          }|dk    r|                    |           3||vr*|                    |           |                    |           bt          |          dk    rdS t	          |          }t          t          |                               |           | j        |                     |d                            }i }d }|D ]}|| j	        v r| j	        |         }t          |t                    rd|\  }	}
 |||
                               |	           |	| j        v r6| j        |	         D ](\  }} |||
|z                                  |           )|| j        v r2| j        |         D ]$\  }	}
 |||
                              |	           %|                                D ]}|                     |           dS )zOverload _insert method to handle ind changes between relative
        objects.  Returns True if some change is made, false otherwise.
        r   r:   Fr   c                 .    || v r	| |         }ng }|| |<   |S rh   rd   )dr7  r   s      rX   
get_or_setz,SymbolicEquivSet._insert.<locals>.get_or_set  s)    AvvaD!HrZ   T)r   r   rE   rx   r  r   rE  r   r   rG  r[   r   r   rH  r   )r   r   indsetuniqsr   r   offset_dictrr  r   r   rX  r   r   r   r   s                 rX   r   zSymbolicEquivSet._insert  s'     	  	 C--$$Cbyy		#Vmm		#

3u::??5U%%--e444t}}U1X667 	 	 	  	A 	ACdk!!C(eU++ M%*NT6J{VG44;;DAAAt{**&*k$&7 M MFQ&J{fqjMBBII!LLLLdk!!&*k#&6 A ANT6J{F33::4@@@@ '')) 	  	 ELLtrZ   c                 j    t          |t          j        t          j        f          sJ || j        |<   dS )z-remember shapes of SetItem IR nodes.
        N)r[   r   StaticSetItemSetItemrI  )r   r   rs   s      rX   set_shape_setitemz"SymbolicEquivSet.set_shape_setitem  s6     # 0"*=>>>>>$rZ   c                 |   t          |t          j        t          j        f          r#t	          || j        v            | j        |         S t          |t          j                  sJ | j        |j                 }t          |t          j
                  r|fS t          t          |                               |          S )zGOverload _get_shape to retrieve the shape of SetItem IR nodes.
        )r[   r   rw  rx  r   rI  r   r   r   r   rk   r   rE  r,  )r   r   r   r   s      rX   r,  zSymbolicEquivSet._get_shape  s     cB,bj9:: 
	EC4?*+++?3''c26*****,sx(C#u// Ev-t44??DDDrZ   )NNNNNNNr   rh   NN)r   r   r   r   r   r   r   r   rQ  rP  r?  r   ry  r,  rB  rC  s   @rX   rE  rE    s-         +
 +
 +
 +
 +
 +
Z. . .


 

 


 
 
1 1 1k k k k k kZ     B, , , , ,\% % %E E E E E E E E ErZ   rE  c                       e Zd ZdZd ZdS )WrapIndexMetaa  
      Array analysis should be able to analyze all the function
      calls that it adds to the IR.  That way, array analysis can
      be run as often as needed and you should get the same
      equivalencies.  One modification to the IR that array analysis
      makes is the insertion of wrap_index calls.  Thus, repeated
      array analysis passes should be able to analyze these wrap_index
      calls.  The difficulty of these calls is that the equivalence
      class of the left-hand side of the assignment is not present in
      the arguments to wrap_index in the right-hand side.  Instead,
      the equivalence class of the wrap_index output is a combination
      of the wrap_index args.  The important thing to
      note is that if the equivalence classes of the slice size
      and the dimension's size are the same for two wrap index
      calls then we can be assured of the answer being the same.
      So, we maintain the wrap_map dict that maps from a tuple
      of equivalence class ids for the slice and dimension size
      to some new equivalence class id for the output size.
      However, when we are analyzing the first such wrap_index
      call we don't have a variable there to associate to the
      size since we're in the process of analyzing the instruction
      that creates that mapping.  So, instead we return an object
      of this special class and analyze_inst will establish the
      connection between a tuple of the parts of this object
      below and the left-hand side variable.
    c                 "    || _         || _        d S rh   )
slice_sizedim_size)r   r  r  s      rX   r   zWrapIndexMeta.__init__/  s    $ rZ   N)r   r   r   r   r   rd   rZ   rX   r}  r}    s-         6! ! ! ! !rZ   r}  c                   h   e Zd ZdZ	 d Zd Zd ZdcdZd Zd Z	d	 Z
d
 Zd Z G d de          Zd Zd Zd Zd Zd Z	 dddZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd  Z d! Z!d" Z"d# Z#d$ Z$d% Z%d& Z&d' Z'd( Z(d) Z)d* Z*d+ Z+d, Z,d- Z-d. Z.d/ Z/d0 Z0d1 Z1d2 Z2d3 Z3d4 Z4d5 Z5d6 Z6d7 Z7d8 Z8d9 Z9d: Z:d; Z;d< Z<d= Z=d> Z>d? Z?d@ Z@dA ZAdB ZBdC ZCdD ZDdE ZEdF ZFdG ZGdH ZHdI ZIdJ ZJdK ZKdL ZLdM ZMdN ZNdO ZOdP ZPdQ ZQdR ZRdS ZSdT ZTdU ZUdV ZVdW ZWdX ZXdY ZYdZ ZZd[ Z[d\ Z\ded]Z]ded^Z^d_ Z_d` Z`da Zadb ZbdS )fArrayAnalysisr   c                     || _         || _        || _        || _        i | _        i | _        i | _        i | _        i | _        d S rh   )	rF   ri  r   	calltypes
equiv_setsarray_attr_callsobject_attrsprependspruned_predecessors)r   rF   ri  r   r  s        rX   r   zArrayAnalysis.__init__>  sL    "  "#%   rZ   c                     | j         |         S )zAReturn the equiv_set object of an block given its label.
        )r  )r   block_labels     rX   r   zArrayAnalysis.get_equiv_setO  s     {++rZ   c                     t                      }|D ]/}| j        D ]%}| j        |         }|                    ||           &0dS )zTake a set of variables in redefineds and go through all
        the currently existing equivalence sets (created in topo order)
        and remove that variable from all of them since it is multiply
        defined within the function.
        N)r   r  r?  )r   
redefinedsunusedr   eslabeless         rX   remove_redefinedszArrayAnalysis.remove_redefinedsT  s_      	% 	%A? % %_W-		!V$$$$%	% 	%rZ   Nc                    || j         j        }t          | j         j                  | j         _        |t	          | j                  }n|}t          || j         j        | j        | j                   \  | _        | _	        t          j        }t          xj        dz  c_        t          j        dk    rt          d|           t          | j         d|           t          j        dk    rIt          dt!          | j                                                             t          d| j                   t'          |          }t)          ||          }|                     ||||           t          j        dk    r]|                                  t          dt!          | j                                                             t          d	| j                   t          | j         d
|           t          j        dk    rt          d|           dS dS )zrun array shape analysis on the given IR blocks, resulting in
        modified IR and finalized EquivSet for each block.
        Nr:   zStarting ArrayAnalysis:zbefore array analysiszArrayAnalysis variable types: zArrayAnalysis call types: )cfgz#ArrayAnalysis post variable types: zArrayAnalysis post call types: zafter array analysiszEnding ArrayAnalysis:)ri  blocksr   _definitionsrE  r   r   	arg_names	alias_maparg_aliasesr  aa_countr   r   r   r
   r  r4  r  r   r	   _run_on_blocksdump)r   r  r   init_equiv_setaa_count_saver  
topo_orders          rX   runzArrayAnalysis.run`  s    >\(F$5dl6I$J$J!-dl;;NN&N+AL"LL	,
 ,
(( &.!#!Q&&+];;;t|%<fEEE!Q&&0&9K9K9M9M2N2N   .???%f--$V555
J^DDD!Q&&IIKKK5t|))++,,   3T^DDDt|%;VDDD!Q&&)=99999 '&rZ   c                     |D ]`}t           j        dk    rt          d|           ||         }|j        }|                     |||||          }|                     ||           ad S )Nr   zProcessing block:)r   r   r   scope_determine_transform_combine_to_new_block)	r   r  r  r  r  labelblockr  pending_transformss	            rX   r  zArrayAnalysis._run_on_blocks  s     	B 	BE%**)51115MEKE!%!:!:UE5." " &&u.@AAAA	B 	BrZ   c                     g }|D ]O\  }}}|D ]}|                     |           |                     |           |D ]}|                     |           P||_        dS )zWCombine the new instructions from previous pass into a new block
        body.
        N)r   body)r   r  r  new_bodyinstprepostinstrs           rX   r  z#ArrayAnalysis._combine_to_new_block  s     1 	' 	'OD#t ' '&&&&OOD!!! ' '&&&&'


rZ   c           	         d}|                     |          }|| j        v r| j        |         }ng }t          j        dk    rt	          d|           |D ]'\  }	}
t          j        dk    rt	          d|	|
           |	|v r,|	| j        v r| j        |	                                         }t          j        dk    rt	          d|           |	|f| j        v rP| j        |	|f         }|D ]>}t                      }| 	                    |||||           | 
                    |           ?||}|                    |          }t                      }|                    |j        |           | 
                    |           )||}|| j        |<   g }|j        D ]l}t                      }| 	                    |||||          \  }}t          |          dk    r| 
                    |           |                    |||f           m|S )zGDetermine the transformation for each instruction in the block
        Nr   zpreds:zp, q:zp in equiv_setsr   )predecessorsr  r   r   r   r  r   r  r   _analyze_instr  r   rA  r   r  rx   r   )r   r  r  r  r  r  r   predsprunedpqfrom_setinstrsr  r<  r  r  r  s                     rX   r  z"ArrayAnalysis._determine_transform  sX    	  ''D,,,-e4FFF !Q&&(E""" 	6 	6FQ%**gq!$$$F{{DO##?1-3355)Q..+X666u:..!]Au:6F & : :$'EE	**!5(D)   ..y9999$ (II ) 3 3H = =I #I((	BBB **9555 &I!*  J 
	9 
	9DI**uiy IC
 9~~!!&&y111%%tS$&78888!!rZ   c                 0    t          d| j                   dS )z@dump per-block equivalence sets for debugging purposes.
        zArray Analysis: N)r   r  r   s    rX   r  zArrayAnalysis.dump  s     	 $/22222rZ   c                     || j         |j        <   |g| j        j        |j        <   t	                      }|                    ||| j        |           d S rh   )r   r   ri  r  r   r?  )r   r   r"  r   r   r  s         rX   _definezArrayAnalysis._define  sN    !$SX/4g!#(+UU
j$,<<<<<rZ   c                       e Zd Zd ZdS )ArrayAnalysis.AnalyzeResultc                     || _         d S rh   )kwargs)r   r  s     rX   r   z$ArrayAnalysis.AnalyzeResult.__init__  s     DKKKrZ   N)r   r   r   r   rd   rZ   rX   AnalyzeResultr    s#        	! 	! 	! 	! 	!rZ   r  c                    %& g }g }t           j        dk    rt          d           t          t          j                  rj        } j        |j                 }	d }
t          |	t          j
                  r|	j        dk    rd}
n<t          j        t          j                  rˉ                     j        |          }|rt          t          |t           j                             d|j        v r|j        d         }
d|j        v r |                    |j        d                    d|j        v r |                    |j        d                    d|j        v r|j        d         _        nRt          j        t          j        t          j        f          r	j        }
nt          j        t          j                  rVj        j        }t          |t.                    rt1          d	 |D                       r|}
nt          |t2                    r|f}
nt          j        t          j                  rt          |	t          j        j                  r't          |	j        t          j                  rj        }
nDt          |	t          j        j                  r%t1          d
 |	j	        D                       rj        }
t          |
t          j                  rct          |
j        t.                    r(|
j         &t/          &fd|
j        D                       }
nt          |
j        t2                    r|
f}
nd }
nt          |
t          j                  r.t           j        |
j                 t          j                  r|
f}
nmt          |
tB                    rX	 "                    || j#        |	           $                    |j                  }|dk    r|j%        |
j&        |
j'        f<   ||fS t          |	t          j
                  r|
Kt          |
t          j                  r1t           j        |
j                 t          j        j(                  rn*|
Dt          |
t.                    s/t          |
t          j                  r3)                    |
          s *                    ||	j        |
|          }
nt          |	t          j                  rH|
rEt          |	j        t          j                  r& *                    |tW          |	          |
|          }
nct          |	t          j        j                  rDt1          d |	j	        D                       r& *                    |tW          |	          |
|          }
	 d}|
,                    ||
          }|r"                    || j#        |	           n{t          t          j-        t          j.        f          rt          t          j.                  rj/        nj0        }tc           j2        j        |          }|sg g fS |d         5t          t          j-        t          j.        f          sJ |d         _/        |d         }|j        d         }d|j        v r|j        d         }3                    j                  }|dk    r4                    |           |g fS | j        j        j                 }t          t          |t          j
                             |j        }||g}j        j        j        j        g} 5                    j         ||          }t          d|j        v            t          d|j        v            |j        d         }
|j        d         }tW          |
          }||k    sJ 4                    |
           ||z   g fS |g fS t          t          j6                  r% fd}j7        %tc          tp           j#        %          }|sO9                    %          }g }|D ]}t          |tt                    r_| j        v rVtc          tp           j#        |d          }t          |t          j                  r|j        }|r|;                    |           v|;                    |           ty          t{          d |                    }ty          |          >                    |          } tW          |           dk    rt          |           d         }nAtW          |          dk    r.tc          tp           j#        t          |          d                   }t          |t          j                  r|j@        dk    r ||           nt          |t          j                  r|j@        dk    rtc          tp           j#        |jA                  }!|!~|!j        t          u rptW          |jC                  dk    rXtc          tp           j#        |jC        d                   }"|"0t          |"t          j                  r|"j@        dk    r ||"           nt          |t          j                  r|j        }t          |t2                    st          |t                    rE|rjD        njE        }#|# jF        v r! jF        |#         ;                               nRg jF        |#<   nFt                    t          v r0t          t                             }$ |$ j                   \  }}||fS )Nr   zanalyze_inst:r   rd   rs   r  r  re  c              3   @   K   | ]}t          |t                    V  d S rh   rT  )rl   r   s     rX   rn   z.ArrayAnalysis._analyze_inst.<locals>.<genexpr>  s,      CCq
1c 2 2CCCCCCrZ   c                 Z    g | ](}t          |t          j        t          j        f          )S rd   r[   r   r]   IntegerLiteralr   s     rX   r   z/ArrayAnalysis._analyze_inst.<locals>.<listcomp>(  sC     , , , ("]E,@AC C , , ,rZ   c              3   B   K   | ]}t          j        |          V  d S rh   )r   r   )rl   r   locs     rX   rn   z.ArrayAnalysis._analyze_inst.<locals>.<genexpr>2  s/      !H!Hq"(1c"2"2!H!H!H!H!H!HrZ   r   c                 Z    g | ](}t          |t          j        t          j        f          )S rd   r  r   s     rX   r   z/ArrayAnalysis._analyze_inst.<locals>.<listcomp>f  sA     ( ( ( $A(<=? ? ( ( (rZ   Tr:   c                 8   d }| j         t          j        k    rj        }j        }d}n%| j         t          j        k    rj        }j        }d}j        | j        j                 }j        | j	        j                 }|t          |t          j                  rt          |t          j                  s4t          |t          j                  rt          |t          j                  rj        }| j        | j	        f}                    |
|          }|                    t#          j        t#          j        ||          	|                     |j        |f<   t#          j        t#          j        d|z
  |          	|          gj        |f<   d S d S d S d S )Nr:   r   )rf  rg  eqtruebrfalsebrner   rd  r   re  r[   r   r]   rj   r  _make_assert_equivr   r   Assignr   r  )cond_defbrotherbrcond_vallhs_typrhs_typr  rI   assertscond_varr   r  r  r  r   s            rX   handle_call_binopz6ArrayAnalysis._analyze_inst.<locals>.handle_call_binop  s   ;(+--B"lG HH[HK//B"kG H,x|'89,x|'89>"7EM:: " 'w>> " #7EO<< " 'w@@ " (C$L(,7D"55sIt G NN	"(8S"9"98SII   29DM5"+.	"(1x<"="=xMM7DM5'"2333' ">>>>>rZ   )lhs_onlyc                 ,    t          | t                    S rh   )r[   r   )r   s    rX   <lambda>z-ArrayAnalysis._analyze_inst.<locals>.<lambda>  s    z!S/A/A rZ   r`  r]  )Ir   r   r   r[   r   r  targetr   r   r   ri   r   r   rb  _analyze_exprr   r  r  r  extendr   r   Globalr   r   r   Arg
containersUniTupledtyper]   Tupler  r}  r?  ri  r   rK  r  r  rj   r*  _gen_shape_callrx   r   rw  rx  r;  	index_varr   _index_to_shaper(  ry  _broadcast_assert_shapesBranchcondr   r   r   r   r   filter
differencer  rc  funcboolrI   r  r  r  r   array_analysis_extensions)'r   r  r  r   r  r<  r  r  rd  r   rs   resultgvaluelhs_indneeds_definer;  target_shapevalue_shape
target_typtarget_ndimshapesr   broadcast_resultr  r   r  r  equivsr   r   var_defdefvars	defconsts	glbl_bool	condition	pruned_brr2   r  r  s'   `````                                @@rX   r  zArrayAnalysis._analyze_inst  s4   !Q&&/4(((dBI&& A	?+C,sx(CE#u455 ''#(a--DJ00 %'++E9dj#NN 	:Jv}/JKKLLL&-// &g 6--

6=#7888..FM&$9:::--%+]5%9
DJ(:;; '
DJ	22 ') vu-- &CCFCCCCC&"EE,, &#IEDJ// 'sE$4$=>>'"39em<<' !JEEsE$4$:;;' , ,!$, , ,  ' !JE%** !ek511 !)C!!H!H!H!HEK!H!H!HHHEES11 !"HEE EEE26** !zUZ(%-0 0 ! E=11 !   isCCC#,,SX66b==   &)5>: Dy #u455 "%"5"&11 &"UZ0%2B2L  & M!%// " #5"&11 " !* 3 3E : :	 " !00!3% E C00  Z	5=AA  00!3C% E 3 0 677	 ( ( Y( ( (  	 ,,sCHHeT   L (55c5AA D  isCCCr/<== A	?(rz::N

  $eYU F  2vay$!$)92:(FGGGGG#AY
AYF!=1L%%mE*#--dj99Kb  ++D,???Bw(!\$+*:;

:u/DEEFFF(o&4)4:?;#'#@#@9dh$ $  #3#::;;;!1!88999(/8*1%8JJ"a''''++D%888W}b((Bwbi(( Y	?! ! ! ! ! ! ! ! ! !F yH^T\8DDH "00::" 
* 
*D!$,, 	*1E1E"'*DL$# # # &grv66 3&-lG" 1 KK000D))))f%A%A4HHIIII0099	y>>Q&&#Iq1HH\\Q&&$&d7mmA6F   H (BG,, F1G1G!!(++++Hbg.. F8;&3H3H!.$,NN	(Y_-D-D8=))Q..$).$,*2-*:%< %<	%1&y"':: 2 ) 7 7--i888h11 .'~Hh,, F
8T0J0J F08 IdkI D$<<<0;BB5IIII?Dg0;$ZZ444)$t**5A$	4<>>ICDyrZ   c                     d                     |j                  }	 t          | |          }n# t          $ r Y d S w xY wt	          |||||          S )Nz_analyze_op_{})r   rc  getattrAttributeErrorr   )r   r  r   rj  rd  rk  rf  s          rX   r  zArrayAnalysis._analyze_expr  se     ''00	u%%BB 	 	 	44	R	4555s   - 
;;c                 \   |j         dk    rC|                     |j        j                  r$|                     |||j        |j        gi           S |j         dk    r5|                    |j                  }t                              |          S |j         dv r?|                     |j        j                  r t                              |j                  S |                     |j                  rt          |j        j        | j
                  }||j         f| j        v r-t                              | j        ||j         f                   S | j        |j                 }g }|                     |||j        d |          }|| j        ||j         f<   t                              ||          S d S )NTrs   rs   )realimag)rs   r  )attr_isarrayr   r    _analyze_op_call_numpy_transposer  r(  r  r  r   r  r  r   r  r   )	r   r  r   rj  rd  rs   canonical_valuer   r  s	            rX   _analyze_op_getattrz!ArrayAnalysis._analyze_op_getattr  s   9djo > >88y$(TZL"   Y'!!''
33E ..U.;;;Y***t}}TZ_/M/M* !..TZ.@@@]]38$$ 	K1
 O  +t/@@@$22+_di,HI 3    l38,,,sCHdD  CH!?DI">?$22T2JJJtrZ   c                 B    t                               |j                  S Nr  )r  r  r   r   r  r   rj  rd  s        rX   _analyze_op_castzArrayAnalysis._analyze_op_cast/  s    ***<<<rZ   c                 0   |j         }| j        |j                 }t          |t          j                  rbt          t          |          |j        k               t          |	                    |                     t                              |          S d S r  )r   r   r   r[   r   rj   r   rx   countr*  r  r  )r   r  r   rj  rd  r"  r   s          rX   _analyze_op_exhaust_iterz&ArrayAnalysis._analyze_op_exhaust_iter2  s~    jl38$c5?++ 	:CHH
*+++I'',,--- ..S.999trZ   static_literal_slice_partc                 &   t          j        |t          |          |          }t          j        ||          }t	          j        |          }	|                    t          j        |||                     |                     |||	|           ||	fS )Nr   r  r  )	r   r   r   r   r   r  r   r  r  )
r   arg_valr  r  stmtsr   r   static_literal_slice_part_varstatic_literal_slice_part_valstatic_literal_slice_part_typs
             rX   gen_literal_slice_partz$ArrayAnalysis.gen_literal_slice_part;  s     )+umD6I6I3(O(O%(*#(>(>%(-(<W(E(E%I34  	
 	
 	
 	)))		
 	
 	
 -.KKKrZ   c                 F    |                      ||z
  ||||d          ^}}|S )Nstatic_slice_sizer3  )r  )	r   lhs_relrhs_relr  r  r  r   the_var_s	            rX   gen_static_slice_sizez#ArrayAnalysis.gen_static_slice_sizeX  s@     11g$ 2 
 
! rZ   c
                    t          |t                    rJ t          j        |t	          d          |          }
t          j                            t          j        |||          }t          j
        }t          |||          | j        |<   |                    t          j        ||
|                     |                     |	|
||           |
|fS )Nexplicit_negr  r  )r[   r   r   r   r   rb  r`  rg  rE   r   r^   r   r  r   r  r  )r   argarg_relarg_typsize_typr  r  dsizer  r   explicit_neg_varexplicit_neg_valexplicit_neg_typs                rX   gen_explicit_negzArrayAnalysis.gen_explicit_nege  s     h,,,,,6%~)F)FLL7==ucs=KK !:+4h,
 ,
'( 	I,5E3OOO	
 	
 	
 	')9;K	
 	
 	
  !111rZ   c                 "   d}t          |t                    rp|dk    rd}nft          |t                    rd}t          ||          }||k    rt          j        dk    rt          d           d}|                     |||	|
|          \  }}|dk    s|dk    sJ |dk    r||j        d         f|_        n|j        d         |f|_        |j        |         }|}|                    |          }n|dk     rd}t          j        dk    rt          d           | 	                    ||||||	||
|	  	        \  }}|dk    r||j        d         f|_        n|j        d         |f|_        |j        |         }|}|                    |          }||||||fS )NFr   Tr   z.Replacing slice to hard-code known slice size.r:   z,Replacing slice due to known negative index.)
r[   r   re   r   r   r   r  rI   rQ  r.  )r   rd  r  r  	dsize_relreplacement_sliceslice_indexneed_replacementr  r  r  r   r)  r*  knownwilliteral_varliteral_typr+  r-  s                       rX   update_replacement_slicez&ArrayAnalysis.update_replacement_slice  s   $ gs## @	1 !||Is++ :1()<< '>>-22NOOO'+$/3/J/JS%	0 0,K '!++{a/?/?/?/?"a'''-2152).. .215'2).
 ,0=C)G'//44G1#' )Q..HIII595J5J
6 
62 "2 !##().q1.%** *.q1(.%*
 (,[9*#++C00
 	
rZ   c                    -./ |j         -t           j        |          }t           j        | j                  \  }}t          |dk    o|dv            t          t          |j                  dk               |j        d         }	|j        d         }
 j        j                 } j        |	j                 } j        |
j                 }t          j
        dk    r't          d| d d	| d
|	 d|
 d| d| d|            t          j        |          }d}t          |t          j                  rt#          j        t'          d          -          }t#          j        d-          }|                    t#          j        ||-                                          |t          j        d          |           |}	t          j        d          }|	|j        d         f|_        d}t          j
        dk    rt          d           t          |t          j                  r9}
|}|j        d         |
f|_        d}t          j
        dk    rt          d                               |	          }                    |
          }                              }t          j
        dk    rt          d|d|d|                                |	||||d|-||          \  }	}}}}}                     |
||||d|-||          \  }
}}}}}t          j
        dk    r t          d|           t          d|           |sd}nt#          j        t'          d          -          }t          j        t          j        f} j        |j        j                                      j        |i           }| j        |<   |                    t#          j        ||-                      j        |j                  j        |j        <   t          j
        dk    rt          dd|d|           |r=|r;t          j
        dk    rt          d                                 ||-|          |fS |dk    rAt          |tB                    r,"                    |d                   r|d         dk    rdfS t          j        }|}t#          j        t'          d          -          }t"          j#        $                    tJ          j&        |
|	-          }tO          |||           j        |<                        |||                               |          }t          j
        dk    rt          d|tQ          |                     t#          j        t'          d           -          /t#          j)        d!tT          -          }tW          tT                    }  j        ,                    | ||fi           .                     /| |           - ./fd"}! |!|	||          \  }"}#}$ |!|
||          \  }%}&}'|                    t#          j        ||-                     |                    t#          j        |/-                     |$*|                    t#          j        |$|"-                     |'*|                    t#          j        |'|%-                     t#          j        t'          d#          -          }(t"          j#        $                    tJ          j&        |%|"-          })tO          ||&|#           j        |)<                        |(||)           |                    t#          j        |)|(-                     t          |tB                    rt          j
        dk    rt          d$j-                   d}*j-        .                                D ]=\  }+},|+d         |d         k    r&"                    |+d         |d                   r|,}* n>|*Yt          j
        dk    rt          d%|*           /                    ||*d                    /                    |(|*d                    n||(fj-        |<   |(|fS )&a  Reason about the size of a slice represented by the "index"
        variable, and return a variable that has this size data, or
        raise GuardException if it cannot reason about it.

        The computation takes care of negative values used in the slice
        with respect to the given dimensional size ("dsize").

        Extra statements required to produce the result are appended
        to parent function's stmts list.
        r^  slicebuiltinsr   r   r:   zslice_size index=z dsize=z index_def=z lhs=z rhs=z
 size_typ=z	 lhs_typ=z	 rhs_typ=FrO   r  Tz$Replacing slice because lhs is None.r  r  r0  z
lhs_known:z
rhs_known:Nr1  zafter rewriting negativesz'lhs and rhs known so return static sizer  r%  size_relwrapra   c                    |szt          j        	t          d                    }t          j        }t           j                            | gi           }
                    |||           
j        |<   |||fS | |d fS )Nr"  )	r   r   r   r   r^   rb  r]  r  r  )r   val_typr4  r"  var_typ	new_valuer*  r   r  r  r   rH   wrap_vars         rX   gen_wrap_if_not_knownz7ArrayAnalysis.slice_size.<locals>.gen_wrap_if_not_known  s     
,fUM%$8$8#>>*GLLC<SII	 YWi@@@,/y)Wi00Wd++rZ   post_wrap_slice_sizezsize_rel is tuplezestablishing equivalence to)0r  r   ri  r   r   r   rx   rI   r   r   r   r   r   r   r[   r   r   r   r   r   r   r   r  r  r  rQ  r8  r^   r  get_call_typerF   r  r"  r   r   rb  r`  rg  rh  r   r   r  ra   r   resolve_function_typerJ  r4  r   )0r   r;  r*  r   r  r  	index_defrk  rl  rd  re  r)  r  r  r1  r3  zero_varrO   r  r  r0  	lhs_known	rhs_knownreplacement_slice_varnew_arg_typsrs_calltype	slice_typorig_slice_typsize_varsize_valr<  wrap_deffntyrC  var1var1_typvalue1var2var2_typvalue2post_wrap_size_varpost_wrap_size_valrel_map_entryrme	rme_tupler  rH   rB  s0   ` ```                                        @@@rX   r  zArrayAnalysis.slice_size  s	    i"4<77	'L)T\
 
 
x 	 =X*%=>>>IN##q()))nQnQ<
+,sx(,sx(!Q&& Me M ME M M(M M/2M M9<M M&M M18M MCJM M N N N !M)44  gu~.. 
	>ve]6%:%:C@@H8As##DLLhCHHHIIILLHe.B1.E.EtLLLC*1--G&)+<+A!+D%E"#%**<=== gu~.. 	>CG&7&<Q&?%E"#%**<===##C((##C((%%e,,	!Q&&7IwY   ))
 
	
. ))
 
	
  !Q&&,	***,	***   	P$(!! %'F}%8993% %! "J
3L,y~':;IIlB K 1<DN,-LL	+0     8<|EJ7ODL.34!Q&&+    	 	%**?@@@**Wc5%  &	  qLL7E** ""5'!*55  
a$;J	"6%|!<!<cBB7==sCS=AA#,Y#I#Ix Y)X>>>$$X..!Q&&*hX7776%v!6!6<<9\:3???":..l00>8,b
 
 	Y$999	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, "7!6sGY!O!Oh!6!6sGY!O!OhRYXhCHHHIIIRYXhCHHHIIILL#FFFGGGLL#FFFGGGV=!788#
 
  W]]8<+/+//2 + 4 4 .7x.
 .
)* 	)96H	
 	
 	
 	I(1C  	
 	
 	
 h&& 	M%**)9+<=== M"+"3"9"9";";  Yq6Xa[((Y-?-?FHQK. .( %.ME( )Q..7GGG&&xq1ABBB&&'9=;KLLLL 089K.L	!(+!#888rZ   c                      j         |j                 }t          t          |t          j                              j         |j                 }                    |          }                    |          }t          |t          j                  r|f}	|f}
nmt          t          |t          j                             t           j
        |          \  }
}t          |dk               t           fd|
D                       }	t          t          |          t          |	          cxk    ot          |          k    nc            g  fd}g }g }d}t          |	|||
          D ][\  }}}} ||||          \  }}|                    |           |d}|                    |           F|                    |           \|rt          |          dk    rt          j        t#          d          |d	         j                  }t          j                            ||d	         j                  }                    t          j        |||d	         j        
                     | j         |j        <   n|d	         }nd}t          |          }t          t-          d |D                                   t          d |D                       }|t.                              |          fS )a  For indexing like var[index] (either write or read), see if
        the index corresponds to a range/slice shape.
        Returns a 2-tuple where the first item is either None or a ir.Var
        to be used to replace the index variable in the outer getitem or
        setitem instruction.  The second item is also a tuple returning
        the shape and prepending instructions.
        build_tuplec              3   <   K   | ]}j         |j                 V  d S rh   r   r   r   s     rX   rn   z0ArrayAnalysis._index_to_shape.<locals>.<genexpr>  s,      ??aT\!&1??????rZ   c                     t          | t          j                  r                    ||          S t          | t          j                  rdS t          d           d S )Nr{  F)r[   r   rk   r  rn  r   )r   r;  r*  r   r  r   r  s      rX   to_shapez/ArrayAnalysis._index_to_shape.<locals>.to_shape  s[    #u// ueYuMMMC.. !z rZ   FNTr:   replacement_build_tupler   r  c              3      K   | ]}|d u V  	d S rh   rd   r   s     rX   rn   z0ArrayAnalysis._index_to_shape.<locals>.<genexpr>?  s&      11aT	111111rZ   c              3      K   | ]}||V  	d S rh   rd   r   s     rX   rn   z0ArrayAnalysis._index_to_shape.<locals>.<genexpr>@  s"      88A!-a----88rZ   rs   r  )r   r   r   r[   r   ri   r,  rk   rj   r   ri  r   rx   ry   r   r   r   r   r  rb  r`  r  r   r  r  )r   r  r   r"  ind_varr   ind_typ	ind_shape	var_shapeseq_typsseqrc  rd  
shape_listindex_var_listreplace_indexrM   r*  orig_ind
shape_partindex_var_partreplacement_build_tuple_varnew_build_tuplers   r  s   ```                     @rX   r  zArrayAnalysis._index_to_shape  sH    l38$
3 566777,w|,((11	((--	gu// 	@zH*CCJw88999)$,@@GCB-'(((????3?????HI#h--AAAA3y>>AAAABBB	 	 	 	 	 	 	 	 
,/090903-5 -5 	0 	0(S$x
 *2#tU)C)C&Jj)))
 ) $%%n5555%%h////  	/>""Q&&.0f!";<<aL$/ /+ #%'"5"5"IaL$4# # I-:%aL,     BI8=>>.<Q.?++*.'j!!C1151111112228888888+++%U+CCE 	ErZ   c                     |                      |||j        |j                  }|d         |d         |_        |d         S r[  )r  r   r;  )r   r  r   rj  rd  r  s         rX   _analyze_op_getitemz!ArrayAnalysis._analyze_op_getitemD  s>    %%eY
DJOO!9 DJayrZ   c                 |   |j         }| j        |j                 }t          |t          j                  s?|                     |||j         |j                  }|d         |d         |_        |d         S |                    |          }t          |j	        t                    rKt          |j	        t          |          k                t                              ||j	                           S t          |j	        t                    r&t                              ||j	                           S t          d           d S )Nr   r:   r  F)r   r   r   r[   r   rj   r  r  r,  r;  r   r   rx   r  r  r:  )	r   r  r   rj  rd  r"  r   r  rs   s	            rX   _analyze_op_static_getitemz(ArrayAnalysis._analyze_op_static_getitemJ  s   jl38$#u// 	))y$*dn F ay$!'!9$$S))dj#&& 	HDJU+,,, ..U4:5F.GGG
E** 	H ..U4:5F.GGGrZ   c                     t          |j        t          v            |                     |j        j                  s|j        t          j        k    r t          	                    |j                  S d S r  )
r   rf  UNARY_MAP_OPr  r   r   rg  rE   r  r  r  s        rX   _analyze_op_unaryzArrayAnalysis._analyze_op_unary\  s^    <'((( ==)) 	ATW-D-D ..TZ.@@@trZ   c                     t          |j        t          v            |                     |||j        |j        |j        g|j                  S rh   )r   rf  BINARY_MAP_OP_analyze_broadcastr  rd  re  r  s        rX   _analyze_op_binopzArrayAnalysis._analyze_op_binopd  sG    =()))&&9dh48(<dg
 
 	
rZ   c                     t          |j        t          v            |                     |||j        |j        |j        g|j                  S rh   )r   rf  INPLACE_BINARY_MAP_OPr  r  rd  re  r  s        rX   _analyze_op_inplace_binopz'ArrayAnalysis._analyze_op_inplace_binopj  sH    00111&&9dh48(<dg
 
 	
rZ   c                 b    |                      |||j        |                                d           S rh   )r  r  	list_varsr  s        rX   _analyze_op_arrayexprz#ArrayAnalysis._analyze_op_arrayexprp  s1    &&9dh(8(8$
 
 	
rZ   c                 n   j         D ]d}t          |t          j                  rHt          | j        |j                 t          j                  r| j        |j                 j        dk    r d S eg }j         D ]6}t          t          | j        |          }||                    |           5 n\t          fd|D                       }t                              |t          j        t          |          j                            S t                              t          j                             S )Nr:   c                 D    g | ]}t          j        |j                  S rd   )r   r   r  )rl   r   rj  s     rX   r   z9ArrayAnalysis._analyze_op_build_tuple.<locals>.<listcomp>  s'    ???1!TX..???rZ   rs   re  r  )r4  r[   r   r   r   r   r   ri   r   r   r   ri  r   r   r  r  r   r  )	r   r  r   rj  rd  r   constsr"  outs	      `     rX   _analyze_op_build_tuplez%ArrayAnalysis._analyze_op_build_tupleu  s-   
  	 	A1bf%%t|AF3U5JKK L(-11tt: 	 	Cj$,44A}a    ???????@@C ..HU6]]DH55 /   
 **tz1B1B*CCCrZ   c           
      b   ddl m} |j        }t          | j        |          }t          |t          j        t          j        f          rAt          |j
                  r-t                              t          |j                            S t          |t          j        t          j        f          rRt          |j
        |          r=|j        }|                     |||j
        |j        |t#          |j                            S t'          | j        || j                  \  }	}
d}t          |
t          j                  r:t          | j        |
j                 t.          j                  r|
g|j        z   }d}
d}n|j        }d                    |
|	                              d	d
          }	|	t6          v r|                     |||j        |d           S 	 t;          | |	          }n# t<          $ r Y d S w xY wt?          ||||j        |t#          |j                            }|r|dd          |_        |S )Nr   )StencilFuncr  r^  FnumpyTz_analyze_op_call_{}_{}.r!  )r  r   r  rI   kwsr:   ) numba.stencils.stencilr  r  r   ri  r[   r   r  FreeVarr   r   r  r  r   rI   _analyze_stencilr  dictr  r   r   r   r   r   ri   r   replaceUFUNC_MAP_OPr  r   r  r   )r   r  r   rj  rd  r  callee
callee_defrI   rk  rl  added_mod_namerf  r  s                 rX   _analyze_op_callzArrayAnalysis._analyze_op_call  sd   666666#DL&99
BJ/
 
 	G!*"233	G !..U495E5E.FFFj29bj"9:: 	zk@
 @
 	 9D(( TX   (L$
 
 
x h'' 	JL')>-
 -
 	 :	)DH!NN9D(//%@@HH
 
 L  **5)+/8T4A A AT5))!   tt#HNN  F  % H	Ms   G! !
G/.G/c                 >   t          t          |          dk               |d         }| j        |j                 }t          t	          |t
          j                             |                    |          }t          	                    |d         |d                   S )Nr:   r   r  )
r   rx   r   r   r[   r   ri   r,  r  r  )	r   r  r   r  rI   r  r"  r   rs   s	            rX   _analyze_op_call_builtins_lenz+ArrayAnalysis._analyze_op_call_builtins_len  s    D		Q1gl38$
3 566777$$S))**quQx*HHHrZ   c                 *     |j         |dd            d S Nr:   )r   r   r  r   r  rI   r  s         rX   :_analyze_op_call_numba_parfors_array_analysis_assert_equivzHArrayAnalysis._analyze_op_call_numba_parfors_array_analysis_assert_equiv  s!     		QRR))trZ   c                     t          t          |          dk               |d         j        }|d         j        }|                    |          }|                    |          }	||	f|j        v rg|j        ||	f         }
t          |
|j        v            |j        |
         }t          |g k               t                              |d         f          S t                              t          ||	                    S )zX Analyze wrap_index calls added by a previous run of
            Array Analysis
        r   r   r:   r  )	r   rx   r   r   rK  r   r  r  r}  )r   r  r   r  rI   r  r  r  slice_eqdim_eqwrap_indr  s               rX   8_analyze_op_call_numba_parfors_array_analysis_wrap_indexzFArrayAnalysis._analyze_op_call_numba_parfors_array_analysis_wrap_index  s     	D		Q!W\
7<,,Z88**844 f!333 )8V*<=HH	 44555%h/BB"H ..beX.>>>
 !..#Hf55 /   rZ   c                     d }t          |          dk    r	|d         }nd|v r|d         }|rt                              |          S t          j        d|          )Nr   rs   r  z'Must specify a shape for array creationr%  )rx   r  r  r   UnsupportedRewriteError)r   r  r   r  rI   r  	shape_vars          rX   _analyze_numpy_create_arrayz)ArrayAnalysis._analyze_numpy_create_array  ss    	t99q==QII^^GI 	@ ..Y.???,5
 
 
 	
rZ   c                 4    |                      |||||          S rh   r  r  s         rX   _analyze_op_call_numpy_emptyz*ArrayAnalysis._analyze_op_call_numpy_empty	  %    //9c4
 
 	
rZ   c                 4    |                      |||||          S rh   r  r  s         rX   7_analyze_op_call_numba_np_unsafe_ndarray_empty_inferredzEArrayAnalysis._analyze_op_call_numba_np_unsafe_ndarray_empty_inferred	  s'     //9c4
 
 	
rZ   c                 4    |                      |||||          S rh   r  r  s         rX   _analyze_op_call_numpy_zerosz*ArrayAnalysis._analyze_op_call_numpy_zeros	  r  rZ   c                 4    |                      |||||          S rh   r  r  s         rX   _analyze_op_call_numpy_onesz)ArrayAnalysis._analyze_op_call_numpy_ones	  r  rZ   c                     t          |          dk    r	|d         }n#d|v r	|d         }nt          j        d|          d|v r	|d         }n|}t                              ||f          S )Nr   Nz,Expect one argument (or 'N') to eye functionr%  Mr  )rx   r   r  r  r  )r   r  r   r  rI   r  r  r  s           rX   _analyze_op_call_numpy_eyez(ArrayAnalysis._analyze_op_call_numpy_eye"	  s    t99q==QAACZZCAA0>    #::CAAA**!Q*888rZ   c                 v    t          |          dk    sJ |d         }t                              ||f          S Nr   r  rx   r  r  )r   r  r   r  rI   r  r  s          rX   _analyze_op_call_numpy_identityz-ArrayAnalysis._analyze_op_call_numpy_identity2	  s;     4yy1}}}}G**!Q*888rZ   c                 B   t          |          dk    sJ |d         }t          |t          j                  sJ | j        |j                 }t          |t          j                  r|j        dk    rod|v r |d         }|	                    |d          sd S |
                    |          \  }	}
|	                    |	|
          rt                              |	f          S n?|j        dk    r4|
                    |          \  }	t                              |	|	f          S d S )Nr   r   r7  r  r:   )rx   r[   r   r   r   r   r   ri   r   r   r,  r  r  )r   r  r   r  rI   r  rm   atypr7  r   r   s              rX   _analyze_op_call_numpy_diagz)ArrayAnalysis._analyze_op_call_numpy_diag9	  s%    4yy1}}}}G!RV$$$$$|AF#dE122 	AyA~~#::CA$--a33 $#t"--a00A%%a++ C(66aT6BBBCa ++A..$22!Q2@@@trZ   c                 b   t          |          dk    sJ |d         }| j        |j                 }t          |t          j                  rt                              d          S t          |t          j                  r0|	                    |          rt                              |          S d S )Nr   )r:   r  )
rx   r   r   r[   r   r]   r  r  ri   r*  )r   r  r   rI   r  r"  r   s          rX   _analyze_numpy_array_likez'ArrayAnalysis._analyze_numpy_array_likeN	  s    4yy1}}}}1gl38$c5=)) 	: ..T.:::U233 	:	8K8K9
 9
 	: !..S.999trZ   c                 `   t          |          dk    sJ |d         }| j        |j                 }t          |t          j                  sJ |j        dk    rW|                    |          rB|j        dk    rt          
                    ||          S t          
                    |          S d S )Nr:   r   Cr  r  )rx   r   r   r[   r   ri   r   r*  layoutr  r  )r   r  r   r  rI   r  r"  r   s           rX   _analyze_op_call_numpy_ravelz*ArrayAnalysis._analyze_op_call_numpy_ravelZ	  s    4yyA~~~~1gl38$#u4555558q==Y0055=zS   %22#2FFF$222===trZ   c                 2    |                      ||||          S rh   r  r  s         rX   _analyze_op_call_numpy_copyz)ArrayAnalysis._analyze_op_call_numpy_copyj	  s    --eYcJJJrZ   c                 2    |                      ||||          S rh   r  r  s         rX   !_analyze_op_call_numpy_empty_likez/ArrayAnalysis._analyze_op_call_numpy_empty_likem	       --eYcJJJrZ   c                 2    |                      ||||          S rh   r  r  s         rX   !_analyze_op_call_numpy_zeros_likez/ArrayAnalysis._analyze_op_call_numpy_zeros_liker	  r  rZ   c                 2    |                      ||||          S rh   r  r  s         rX    _analyze_op_call_numpy_ones_likez.ArrayAnalysis._analyze_op_call_numpy_ones_likew	  r  rZ   c                 2    |                      ||||          S rh   r  r  s         rX    _analyze_op_call_numpy_full_likez.ArrayAnalysis._analyze_op_call_numpy_full_like|	  r  rZ   c                 2    |                      ||||          S rh   r  r  s         rX   %_analyze_op_call_numpy_asfortranarrayz3ArrayAnalysis._analyze_op_call_numpy_asfortranarray	  r  rZ   c                    t          |          }|dk    sJ |dk    rS| j        |d         j                 }t          |t          j                  r!t                              |d                   S g }d}	t          dt          |                    D ]p}
||
         }t          t          | j        |          }t          |t          j                  r1|j        dk     r&|	dk    r|
}	Sd}t          j        ||j                  q|	dk    r|d         j        }t          j        |t'          d          |          }t          j        | j        |j        <   t          j        t          j                            |d         d	|          ||          }|                    |           t          dt          |                    D ]}
|
|	k    r	t          j        |t'          d          |          }t          j        | j        |j        <   t          j                            t4          j        |||
         |          }t          j        |||          }t9          t          j        t          j        t          j                  | j        |<   |                    |           |}|||	<   t                              t=          |dd                    |
          S )Nr:   r   r  r   r   z7The reshape API may only include one negative argument.r%  calc_size_varrM   rh  )rx   r   r   r[   r   rj   r  r  r   r   r   ri  r   r   r   r   r  r  r   r   r^   r  rb  r   r   r`  rg  floordivr   r  r   )r   r  r   r  rI   r  r   r   r  neg_one_index	arg_indexreshape_argreshape_arg_defr   r  init_calc_vardiv_calc_size_var	new_binopdiv_calcs                      rX   _analyze_op_call_numpy_reshapez,ArrayAnalysis._analyze_op_call_numpy_reshape	  s   II1uuuu66,tAw|,C#u// B$22a2AAA q#d)),, 	 	Iy/K#NDL+NNO/2844 	"(1,,$**(1 ,$<[_    A q'+CF5-*H*H#NNM/4zDL+,IQ55}c M LL''' #1c$ii00 2 2	--$&F=993% %! 8=z.34 GMM%}d9os 	 9Y0A3GG,5J
EJ- -y) X&&& 1 #0D**tABBxe*LLLrZ   c                 @   
 |d         } j         |j                 }t          |t          j                  s
J d            |                    |          
t          |          dk    r5t                              t          t          
                              S  fd|dd          D             }t          |d         t                    rt          |d                   }d |v rd S 
fd|D             }	t                              t          |	                    S )Nr   zInvalid np.transpose argumentr:   r  c                 F    g | ]}t          t          j        |          S rd   )r   r   ri  )rl   rm   r   s     rX   r   zBArrayAnalysis._analyze_op_call_numpy_transpose.<locals>.<listcomp>	  s'    EEEqj$,22EEErZ   c                      g | ]
}|         S rd   rd   )rl   r   rs   s     rX   r   zBArrayAnalysis._analyze_op_call_numpy_transpose.<locals>.<listcomp>	  s    &&&AuQx&&&rZ   )r   r   r[   r   ri   r,  rx   r  r  r   reversedr  )r   r  r   r  rI   r  in_arrr   axesretrs   s   `         @rX   r	  z.ArrayAnalysis._analyze_op_call_numpy_transpose	  s!    al6;'&
 
 	+ 	+*	+ 	+ 	+ $$V,,t99>> ..U8E??5K5K.LLLEEEEDHEEEd1gu%% 	!Q==D4<<4&&&&&&&**s*<<<rZ   c                 |    t          |          dk    r(t                              t          |                    S d S r  )rx   r  r  r   r  s         rX   "_analyze_op_call_numpy_random_randz0ArrayAnalysis._analyze_op_call_numpy_random_rand	  s5     t99q== ..U4[[.AAAtrZ   c                 4    |                      |||||          S rh   )r  r  s         rX   #_analyze_op_call_numpy_random_randnz1ArrayAnalysis._analyze_op_call_numpy_random_randn	  s'     669c4
 
 	
rZ   c                     d|v r!t                               |d                   S t          |          |k    r!t                               ||                   S d S )NrM   r  )r  r  rx   )r   posr  r   rI   r  s         rX   "_analyze_op_numpy_random_with_sizez0ArrayAnalysis._analyze_op_numpy_random_with_size	  sW     S== ..S[.AAAt99s?? ..T#Y.???trZ   c                 4    |                      d||||          S rc   r  r  s         rX   "_analyze_op_call_numpy_random_ranfz0ArrayAnalysis._analyze_op_call_numpy_random_ranf	  '     66uis
 
 	
rZ   c                 4    |                      d||||          S rc   r  r  s         rX   +_analyze_op_call_numpy_random_random_samplez9ArrayAnalysis._analyze_op_call_numpy_random_random_sample
  r  rZ   c                 4    |                      d||||          S rc   r  r  s         rX   $_analyze_op_call_numpy_random_samplez2ArrayAnalysis._analyze_op_call_numpy_random_sample
  r  rZ   c                 4    |                      d||||          S rc   r  r  s         rX   $_analyze_op_call_numpy_random_randomz2ArrayAnalysis._analyze_op_call_numpy_random_random
  r  rZ   c                 4    |                      d||||          S rc   r  r  s         rX   -_analyze_op_call_numpy_random_standard_normalz;ArrayAnalysis._analyze_op_call_numpy_random_standard_normal
  r  rZ   c                 4    |                      d||||          S r  r  r  s         rX   '_analyze_op_call_numpy_random_chisquarez5ArrayAnalysis._analyze_op_call_numpy_random_chisquare
  r  rZ   c                 4    |                      d||||          S r  r  r  s         rX   %_analyze_op_call_numpy_random_weibullz3ArrayAnalysis._analyze_op_call_numpy_random_weibull$
  r  rZ   c                 4    |                      d||||          S r  r  r  s         rX   #_analyze_op_call_numpy_random_powerz1ArrayAnalysis._analyze_op_call_numpy_random_power+
  r  rZ   c                 4    |                      d||||          S r  r  r  s         rX   '_analyze_op_call_numpy_random_geometricz5ArrayAnalysis._analyze_op_call_numpy_random_geometric2
  r  rZ   c                 4    |                      d||||          S r  r  r  s         rX   )_analyze_op_call_numpy_random_exponentialz7ArrayAnalysis._analyze_op_call_numpy_random_exponential9
  r  rZ   c                 4    |                      d||||          S r  r  r  s         rX   %_analyze_op_call_numpy_random_poissonz3ArrayAnalysis._analyze_op_call_numpy_random_poisson@
  r  rZ   c                 4    |                      d||||          S r  r  r  s         rX   &_analyze_op_call_numpy_random_rayleighz4ArrayAnalysis._analyze_op_call_numpy_random_rayleighG
  r  rZ   c                 4    |                      d||||          S Nr   r  r  s         rX   $_analyze_op_call_numpy_random_normalz2ArrayAnalysis._analyze_op_call_numpy_random_normalN
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   %_analyze_op_call_numpy_random_uniformz3ArrayAnalysis._analyze_op_call_numpy_random_uniformU
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   "_analyze_op_call_numpy_random_betaz0ArrayAnalysis._analyze_op_call_numpy_random_beta\
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   &_analyze_op_call_numpy_random_binomialz4ArrayAnalysis._analyze_op_call_numpy_random_binomialc
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   _analyze_op_call_numpy_random_fz-ArrayAnalysis._analyze_op_call_numpy_random_fj
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   #_analyze_op_call_numpy_random_gammaz1ArrayAnalysis._analyze_op_call_numpy_random_gammaq
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   '_analyze_op_call_numpy_random_lognormalz5ArrayAnalysis._analyze_op_call_numpy_random_lognormalx
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   %_analyze_op_call_numpy_random_laplacez3ArrayAnalysis._analyze_op_call_numpy_random_laplace
  r  rZ   c                 4    |                      d||||          S r
  r  r  s         rX   %_analyze_op_call_numpy_random_randintz3ArrayAnalysis._analyze_op_call_numpy_random_randint
  r  rZ   c                 4    |                      d||||          S )N   r  r  s         rX   (_analyze_op_call_numpy_random_triangularz6ArrayAnalysis._analyze_op_call_numpy_random_triangular
  r  rZ   c           	      
   t          |          dk    sJ |d         j        }t          | j        |d                   \  }}t          |          }t	          |dk               d}	d|v r@t          |d         t                    r	|d         }	nJt          | j        |d                   }	n.t          |          dk    rt          | j        |d                   }	t	          t          |	t                               t	          |dk               fd|D             }
|	dk     rt          |
d                   |	z   }	t	          d|	cxk    ot          |
d                   k     nc            g }g }|dk    r|
d         }                    |
d                   }|	                    d           t          t          |                    D ]K|	k    r'                    |                   }|r|r||z  nd }/|                     |
d                   }L|                    |           nt          t          |
d                             D ]|	k    r#|                     fd|
D                       }nAfd|
D             }|                    |                     |||                     |d         }|                    |           t                              t!          |          t#          |g                     S )	Nr   axisr:   r`  c                 :    g | ]}                     |          S rd   r,  rl   r   r   s     rX   r   zDArrayAnalysis._analyze_op_call_numpy_concatenate.<locals>.<listcomp>
  '    777a)&&q))777rZ   c                      g | ]
}|         S rd   rd   rl   rs   r   s     rX   r   zDArrayAnalysis._analyze_op_call_numpy_concatenate.<locals>.<listcomp>
  s    #A#A#AE!H#A#A#ArZ   c                      g | ]
}|         S rd   rd   r&  s     rX   r   zDArrayAnalysis._analyze_op_call_numpy_concatenate.<locals>.<listcomp>
  s    :::%U1X:::rZ   rh  )rx   r  r   ri  r   r[   r   r   r   popr   	_sum_sizer   _call_assert_equivr  r  r   r  )r   r  r   r  rI   r  rn  rc  r   r   r  r  	new_shapers   r   rM   sizesr   s     `              @rX   "_analyze_op_call_numpy_concatenatez0ArrayAnalysis._analyze_op_call_numpy_concatenate
  s    4yy1}}}}1gk%dlDG<<RHHAS==#f+s++ =6{!$,F<<YY]]dlDG44D
4%%&&&m#$$$77773777!88vay>>D(DT****Cq	NN****+++	661IE))&)44AIIaLLL3u::&& @ @99!11%(;;A%&7171q554DD>>)VAY??DDT""""3vay>>** ' '99>>!#A#A#A#A&#A#A#A DD ;:::6:::ENN//sIuMM   !8D  &&&&**	""GR   + 
 
 	
rZ   c                    t          |          dk    sJ |d         j        }t          | j        |d                   \  }}t          |          }t	          |dk               d}	d|v r@t          |d         t                    r	|d         }	nJt          | j        |d                   }	n.t          |          dk    rt          | j        |d                   }	t	          t          |	t                               t	          |dk               fd|D             }
|                     |||          }|
d         }|	dk     rt          |          |	z   dz   }	t	          d|	cxk    ot          |          k    nc            t          |d|	                   |gz   t          ||	d                    z   }t                              t          |          |          S )Nr   r   r:   r`  c                 :    g | ]}                     |          S rd   r"  r#  s     rX   r   z>ArrayAnalysis._analyze_op_call_numpy_stack.<locals>.<listcomp>
  r$  rZ   rh  )rx   r  r   ri  r   r[   r   r   r*  r  r  r  r   )r   r  r   r  rI   r  rn  rc  r   r   r  r  rs   r+  s     `           rX   _analyze_op_call_numpy_stackz*ArrayAnalysis._analyze_op_call_numpy_stack
  s   4yy1}}}}1gk%dlDG<<RHHAS==#f+s++ =6{!$,F<<YY]]dlDG44D
4%%&&&m#$$$77773777))%iEEq	!88u::$q(DT''''SZZ''''(((qv''1#-U455\0B0BB	**y1A1Aw*OOOrZ   c                    t          |          dk    sJ t          | j        |d                   \  }}t          |          }t          |dk               | j        |d         j                 }	t          t          |	t          j                             |	j	        dk     r| 
                    |||||          S d|d<   |                     |||||          S Nr:   r   r   r   )rx   r   ri  r   r   r   r[   r   ri   r   r0  r-  
r   r  r   r  rI   r  rn  rc  r   r   s
             rX   _analyze_op_call_numpy_vstackz+ArrayAnalysis._analyze_op_call_numpy_vstack
  s    4yyA~~~~%dlDG<<RHHAl3q6;'
3 5667778a<<44y#tS   CK::y#tS  rZ   c                    t          |          dk    sJ t          | j        |d                   \  }}t          |          }t          |dk               | j        |d         j                 }	t          t          |	t          j                             |	j	        dk     rd|d<   nd|d<   | 
                    |||||          S r2  )rx   r   ri  r   r   r   r[   r   ri   r   r-  r3  s
             rX   _analyze_op_call_numpy_hstackz+ArrayAnalysis._analyze_op_call_numpy_hstack
  s    4yyA~~~~%dlDG<<RHHAl3q6;'
3 5667778a<<CKKCK669c4
 
 	
rZ   c                    t          |          dk    sJ t          | j        |d                   \  }}t          |          }t          |dk               | j        |d         j                 }	t          t          |	t          j                             |	j	        dk    rbd|d<   | 
                    |||||          }
t          |
           t          dgt          |
j        d                   z             |
j        d<   |
S |	j	        dk    rd|d<   | 
                    |||||          S d|d<   |                     |||||          S )Nr:   r   r   rs   r   )rx   r   ri  r   r   r   r[   r   ri   r   r0  r   r  r  r-  )r   r  r   r  rI   r  rn  rc  r   r   r  s              rX   _analyze_op_call_numpy_dstackz+ArrayAnalysis._analyze_op_call_numpy_dstack  sJ   4yyA~~~~%dlDG<<RHHAl3q6;'
3 5667778q==CK66y#tS F FOOO%*A3fmG6L1M1M+M%N%NFM'"MX]]CK44y#tS   CK::y#tS  rZ   c                     d S rh   rd   r  s         rX   _analyze_op_call_numpy_cumsumz+ArrayAnalysis._analyze_op_call_numpy_cumsum      trZ   c                     d S rh   rd   r  s         rX   _analyze_op_call_numpy_cumprodz,ArrayAnalysis._analyze_op_call_numpy_cumprod"  r;  rZ   c                     t          |          }d}|dk    r	|d         }nd|v r|d         }t                              |f          S )N2   r   numr  r  )r   r  r   r  rI   r  r   r@  s           rX   _analyze_op_call_numpy_linspacez-ArrayAnalysis._analyze_op_call_numpy_linspace&  sS     IIq55q'CCc\\e*C**#*888rZ   c                     t          |          }|dk    sJ |d         j        }t          t           fd|D                                   fd|D             }d |D             }t          t          d |D                                  |d         dk    r|d         dk    rd S fd|D             }	|d         dk    rz                     |||	d         d         |	d         d	         g          }
t
                              t          |	d         dd	         |	d         d
d          z             |
          S |d         dk    ri                     |||	d         d
         |	d         d         g          }
t
                              t          |	d         dd
                   |
          S |d         dk    rt|d         dk    rh                     |||	d         d         |	d         d         g          }
t
                              |	d         d         |	d         d         f|
          S |d         dk    r	 d S )Nr   r   c                 D    g | ]}                     |j                  S rd   r  r   r   s     rX   r   z<ArrayAnalysis._analyze_op_call_numpy_dot.<locals>.<listcomp>5  s'    999qT]]16**999rZ   c                 4    g | ]}j         |j                 S rd   rb  r   s     rX   r   z<ArrayAnalysis._analyze_op_call_numpy_dot.<locals>.<listcomp>6  s"    333QV$333rZ   c                     g | ]	}|j         
S rd   )r   )rl   tys     rX   r   z<ArrayAnalysis._analyze_op_call_numpy_dot.<locals>.<listcomp>7  s    '''B'''rZ   c              3   "   K   | ]
}|d k    V  dS )r   Nrd   r   s     rX   rn   z;ArrayAnalysis._analyze_op_call_numpy_dot.<locals>.<genexpr>8  s&      ((aAE((((((rZ   r:   c                 :    g | ]}                     |          S rd   r"  r#  s     rX   r   z<ArrayAnalysis._analyze_op_call_numpy_dot.<locals>.<listcomp>;  s'    888a)&&q))888rZ   r   rh  )rx   r  r   r   r*  r  r  r   )r   r  r   r  rI   r  r   typsdimsr  r  s   ` `        rX   _analyze_op_call_numpy_dotz(ArrayAnalysis._analyze_op_call_numpy_dot1  s~   IIAvvvv1gk9999D999::;;;3333d333''$'''((4((((()))7a<<DGqLL4888848887a<<--sIq	!fQim'D G !..F1IadOfQin<== /    7a<<--sIq	"vay|'D G !..F1IadO,, /    7a<<DGqLL--sIq	!fQil'C G !..ay|VAYq\2 /    7Q;;trZ   c                    |j                             dd          }|j        j        }t	          |t
                    r|f}g }	t          |          dk    r t          |          t          |          k    sJ t          ||          D ]J\  }
}| j        |j	                 }t	          |t          j                  r|
|vr|	                    |           Kt          |	          }t          |dk               |                     ||||	          }|                    |	d                   }t                               ||          S )Nstandard_indexingrd   r   rh  )optionsr   	kernel_irr  r[   r   rx   ry   r   r   r   ri   r   r   r*  r(  r  r  )r   r  r   stencil_funcr  rI   r  std_idx_arrskernel_arg_namesrel_idx_arrsr&  r"  r   r   r  rs   s                   rX   r  zArrayAnalysis._analyze_stencilX  s;    $+//0CRHH'1;lC(( 	+(?L4yy1}}Tc2B.C.C!C!C!C!C,d33 	) 	)HC,sx(C#u455 )|####C(((A))%iNN##LO44**G*DDDrZ   c                     t          t          |          dk               t                              |                    |d                             S )Nr:   r   r  )r   rx   r  r  r,  r  s         rX   !_analyze_op_call_numpy_linalg_invz/ArrayAnalysis._analyze_op_call_numpy_linalg_invm  sE     	D		Q**1E1Ed1g1N1N*OOOrZ   c           
          t          t           fd|                    }t          |          dk    r
|j        dk    r j        |d         j                 } j        |d         j                 }|j        dk    r4t                              	                    |d                             S |j        dk    r4t                              	                    |d                             S 	 fd|D             }	d|	v rdS t          |	d	          }
t                              |
          S # t          $ r Y dS w xY wt          t           fd
|                    }t          t          |          dk               d |D             } fd|D             }t          |          }t          |dk               	 fd|D             }	nH# t          $ r; t                              |d                              |||                    cY S w xY wg }d|	v r~g }t          |	          D ]j\  }}|N||         } j        |j                 }                     ||j        d|          }|                    |           U|                    |           k|}	                     |||	|          }|r&d|j        v r|j        d         }ng }||z   |j        d<   |S )zInfer shape equivalence of arguments based on Numpy broadcast rules
        and return shape of output
        https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
        c                 8                         | j                  S rh   )_istupler   rm   r   s    rX   r  z2ArrayAnalysis._analyze_broadcast.<locals>.<lambda>x      T]]16%:%: rZ   r   rE   r   r:   r  c                 :    g | ]}                     |          S rd   r'  r#  s     rX   r   z4ArrayAnalysis._analyze_broadcast.<locals>.<listcomp>  s'    ???Q)--a00???rZ   Nrd   c                 8                         | j                  S rh   rD  r[  s    rX   r  z2ArrayAnalysis._analyze_broadcast.<locals>.<lambda>  r\  rZ   c                     g | ]	}|j         
S rd   r3  r   s     rX   r   z4ArrayAnalysis._analyze_broadcast.<locals>.<listcomp>  s    &&&A&&&rZ   c                 >    g | ]}j         |j                 j        S rd   )r   r   r   r   s     rX   r   z4ArrayAnalysis._analyze_broadcast.<locals>.<listcomp>  s%    888aQV$)888rZ   c                 :    g | ]}                     |          S rd   r'  r#  s     rX   r   z4ArrayAnalysis._analyze_broadcast.<locals>.<listcomp>  s'    ;;;i))!,,;;;rZ   rh  r  )r  r  rx   r   r   r   r  r  r  r(  r  r   r   r   r*  	enumerater  r   r   r  r  )r   r  r   r  rI   rf  tupstup0typtup1typr  concat_shapesarrsr   rL  max_dimr  
new_shapesr   sr"  r   rs   r  prev_pres   ` `                     rX   r  z ArrayAnalysis._analyze_broadcasts  so   
 F::::DAABBt99>>bkU22 l47<0Gl47<0G}!!$22#--d1g66 3    }!!$22#--d1g66 3   	????$???6>>4 #FB$22' 3    "   tt F::::DAABBD		A&&&&&88884888d))!	;;;;d;;;FF 	 	 	 ..1g++E3	4HH /     	
 6>> J!&)) 	) 	)19q'C,sx0C 00!3$ E %%e,,,,%%a((((F..9c65
 
  	2 %%!=/#&>FM% s+   1D0 *D0 0
D>=D>>G AHHc           
         g }g }t          d |D                       }d}	t          |          D ]}
g }g }t          ||          D ]{\  }}|
t          |          k     rc|t          |          dz
  |
z
           }|                    |          }|dk    r|}	Q|                    |           |                    |           ||g k    r.|	J |                    |	           |                    d           |                    |                     |||||                     |                    |d                    t                              t          t          |                    t          |g                     S )zProduce assert_equiv for sizes in each dimension, taking into
        account of dimension coercion and constant size of 1.
        c                 ,    g | ]}t          |          S rd   r  )rl   rs   s     rX   r   z:ArrayAnalysis._broadcast_assert_shapes.<locals>.<listcomp>  s    666es5zz666rZ   Nr:   1r   r   rh  )r   r   ry   rx   r   r   r*  r  r  r   r  r  )r   r  r   r  r  r   r  r+  rh  const_size_oner   r,  
size_namesr   rs   rM   
const_sizes                    rX   r  z&ArrayAnalysis._broadcast_assert_shapes  s    	66v66677w 	' 	'AEJ"5&11 0 0es5zz>> Ua!!34D!*!:!:4!@!@J!Q)-T***"))$///{{%111^,,,!!#&&&NN''3	5
 (    
 U1X&&&&**++,,GR   + 
 
 	
rZ   c                 t    |                      |||||          }t          |          dk    r
 |j        |  |S )Nro  r:   )r  rx   r   )r   r  r  r   rI   r   instss          rX   r*  z ArrayAnalysis._call_assert_equiv  sM    ''3	4u ( 
 
 t99q=="I"D))rZ   c           
      L    t           j        dk    rt          d||           |d |D             }g }g }t          ||          D ]\  }}	t           j        dk    rt          d||	           d}
|D ]Q}t           j        dk    r%t          d||                    |	|                     |                    |	|          rd}
 nR|
s*|                    |	           |                    |           t          |          dk     r!t           j        dk    rt          d           g S d	                    d
                    |          |          }t          j
        ||          }t          j        |          }t          j        |t          d          |          }| j        |j        <   t#          |g fd|D             z             }t          j                            |          }t          j        |t          d          |          }t          j        dt*          |          }t-          t*                    } j                            ||fi           }                     ||||           t          j        |t          d          |          }t          j                            ||g|z   i |          }                     ||t          j        |           | j        |<   t          j        |||          t          j        |||          t          j        |||          gS )Nr   zmake_assert_equiv:c                     g | ]	}|j         
S rd   r3  r   s     rX   r   z4ArrayAnalysis._make_assert_equiv.<locals>.<listcomp>  s    +++QV+++rZ   zname, x:Fzis equiv to?Tz@Will not insert assert_equiv as args are known to be equivalent.zSizes of {} do not match on {}z, r   c                 4    g | ]}j         |j                 S rd   rb  r   s     rX   r   z4ArrayAnalysis._make_assert_equiv.<locals>.<listcomp>  s"    $H$H$HaT\!&%9$H$H$HrZ   assertr   r%  r  r  )r   r   r   ry   r   r   rx   r   joinr   r   r   r   r   r   r   r   r   r   
from_typesr  r   r   rF   rF  r  rb  r]  r   r  r  )r   r  r  r   _argsr   rI   r  r   r   seenrU  r   msg_valmsg_typmsg_varargtypstup_typ
assert_var
assert_defrS  rH   r"  r   s   `                       rX   r  z ArrayAnalysis._make_assert_equiv  s,   !Q&&&u555=++U+++E	5%(( 	' 	'GD!%**j$***D  )Q...!Y-?-?1-E-EFFF%%a++ DE  'A  &&& t99q==%**"   I.55IIi  #
 
 (3$$%c**&e 4 4c::%,W\"	$H$H$H$H4$H$H$HHII $//88 VE=#:#:C@@
Y~|EEE
"<00l00z2FFY
D*=== fUM%00#66Z'T)923GGYUZ777 #u IGG===IJzsCCCIE#3777
 	
rZ   c           
         t          |t          j                  r|                    |          }t          |t          j                  r|}d }d }nt          |t          j                  r|}d }d }nt          j                            |d|j                  }t          j        |j        t          d
                    |j                            |j                  }t          j                            t          j        |          }g }	d}
|r"t!          |          }||k     r|||z
  d          }t#          |          D ]R}d}|rj||         rat          ||         t          j                  rI| j        ||         j                 }t          |t          j        t          j        f          r
||         }d}nt          ||         t*                    r!t          j        ||         |j                  }n||         }t          |t          j                  sJ t          j        |j        t          d
                    |j        |                    |j                  }|                    t          j        |||j                             |                     ||t          j        |           d}|st          j        |j        t          d
                    |j        |                    |j                  }t          j                            ||d |j                  }d}
d | j        |<   |                    t          j        |||j                             |                     ||t          j        |           |	                    |           T|
rI|rG|                    dt          j        |||j                             |                     ||||           t;          |	          S )Nrs   z{}_shapeFTz	{}_size{}r   )r[   r   r   r(  r  rb  r   r  r  r   r   r   r   r  r  r^   rx   r   r   rn  rk   r   r   r   r  r  static_getitemr  r   r   )r   r   r"  r  rs   r  attr_varshape_attr_callshape_attr_typ	size_varsuse_attr_varnshapesr   skipr   rP  rQ  getitems                     rX   r  zArrayAnalysis._gen_shape_call(  s   eRV$$ 	/''..E eRV$$ 	JH"OEErv&& 		JH"OEE gooc7CGDDOv	=):):38)D)DEEsw H #-66uz5IIN	 	3%jjGww112u "	' "	'AD  q  eAh//  ,uQx}5C!#eo'FGG $#(8#!%(C00 ,#%8E!Hcg#>#>#(8%h99999!v	%k&8&81&E&EFF   H
 KK	(Hcg F FGGGLLHej(KKKD G6I!+"4"4SXq"A"ABBG 
 '001dCGLL#*.w'BIgxAABBBY%*gFFFX&&&& 	OO 	OKK29_hHHIIILLHnoNNNYrZ   c                 p    | j         |         }t          |t          j        j                  o
|j        dk    S rc   )r   r[   r   npytypesArrayr   r   varnamer   s      rX   r  zArrayAnalysis._isarrayl  s.    l7##u~344EAErZ   c                 P    | j         |         }t          |t          j                  S rh   )r   r[   r   rj   r  s      rX   rZ  zArrayAnalysis._istuplep  s     l7##u///rZ   c                 R    d}|D ]!}|                     |          }| dS ||z  }"|S )zzReturn the sum of the given list of sizes if they are all equivalent
        to some constant, or None otherwise.
        r   N)r   )r   r   r,  rj  rM   r   s         rX   r)  zArrayAnalysis._sum_sizet  sG      	 	D))$//AyttQrZ   r{  )r  rh   )cr   r   r   r  r   r   r  r  r  r  r  r  r  objectr  r  r  r  r  r  r  r"  r.  r8  r  r  rx  rz  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  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r-  r0  r4  r6  r8  r:  r=  rA  rM  r  rW  r  r  r*  r  r  r  rZ  r)  rd   rZ   rX   r  r  4  s,       H& & &", , ,

% 
% 
%0: 0: 0: 0:d	B 	B 	B  B" B" B"H3 3 3
= = =! ! ! ! ! ! ! !H H HT6 6 6  @= = =    )L L L L:  2 2 2>[
 [
 [
zG9 G9 G9RXE XE XEt    $  
 
 

 
 

 
 

D D D:= = =~I I I    >
 
 

 
 


 
 

 
 


 
 

9 9 9 9 9 9  *
 
 
   K K KK K K
K K K
K K K
K K K
K K K
HM HM HMT= = =&  
 
 
  
 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 

 
 
4
 4
 4
lP P P4  "
 
 
  4    	9 	9 	9% % %NE E E*P P PJ J JX!
 !
 !
F   <
 <
 <
 <
|B  B  B HF F F0 0 0    rZ   r  c                     g | ]	}|j         
S rd   )r   )rl   r2   s     rX   r   r     s    ===q
===rZ   )Ar  rg  
numba.corer   r   r   r   r   numba.core.ir_utilsr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   numba.core.analysisr   numba.core.typingr   r   r   numba.core.extendingr   rA   UNKNOWN_CLASSCONST_CLASSufunc	MAP_TYPESr  array_creationrandom_int_argsrandom_1arg_sizerandom_2arg_sizelastrandom_3arg_sizelastrandom_callsra   re   r   r  r   r   rE  r}  r  r  NumpyRulesUnaryArrayOperator_op_mapkeysr  r|  NumpyRulesArrayOperatorr  NumpyRulesInplaceArrayOperatorr  supported_ufuncsr  rd   rZ   rX   <module>r     s     9 9 9 9 9 9 9 9 9 9 9 9 9 9                                 " 8 7 7 7 7 7 0 0 0 0 0 0 0 0  * * * * * * [M	  4337#      	 	 	    ,	   ,5 ,5 ,5^
 
 
 =0 =0 =0@V V V V Vv V V Vrz* z* z* z* z*H z* z* z*zkE kE kE kE kE} kE kE kE\	! ! ! ! !F ! ! !BK! K! K! K! K!F K! K! K!\B tG8@EEGGHHLL  /7<<>>>FKKMM ==G$<===rZ   