
    J/PhCj                        d dl mZ d dlZd dlmZmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZmZ  edg d	          Zd
 Zd Zd Zd Zd Zd Z G d de          Z ed          Z G d de          Z G d de          Zd Zd Z G d de          Z G d de          Z  G d de          Z! G d d e!          Z"dS )!    )
namedtupleN)Constant	IRBuilder)ir)typescgutils)global_compiler_lock)make_library_cache	NullCache_wrapper_infolibraryenvnamec                 $    |             }|j                             |||	j        |	j        |          \  }}|                    |j        d          5 \  }}|5   ||           d d d            n# 1 swxY w Y   |5  |
                                }|j                             ||
|           |
                    |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          ||          D ]G\  }}|
                    |                    |                    |          |j                  |           H|
                    |                    |                    |          |j                  |           |j        S NTlikely)	call_convcall_functionreturn_typeargsif_elseis_ok
gil_ensureraise_errorgil_releasezipstoreaddloadstepcode)r!   r   contextfuncbuilderarraysoutoffsetsstore_offset	signaturepyapir   elemsstatusretvalif_okif_errorgiloffarys                       W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/np/ufunc/wrappers.py_build_ufunc_loop_bodyr6      sG   DFFE &44Wd5>5J5>^UL LNFF
 
d	3	3 #7Hx 	 	E&MMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	# 	#""$$C))'5&AAAc"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	## # # # # # # # # # # # # # # (( E ESgkk',,s"3"3SX>>DDDDMM'++gll<88#(CC      ;s[   C&A0$C&0A4	4C&7A4	8C&=ACC&C	C&C	C&&C*-C*c                     |             }t           j        gt          |	j                  z  }|                    d          5  |j                            ||t           j        ||          \  }}|D ]}|                    |           	 d d d            n# 1 swxY w Y    ||           t          ||          D ]G\  }}|	                    |
                    |                    |          |j                  |           H|	                    |
                    |                    |          |j                  |           |j        S )NT)keep_new)r   pyobjectlenr   err_pushr   r   decrefr   r   r    r!   r"   r#   )r!   r   r$   r%   r&   r'   r(   r)   r*   r+   r   r,   r-   _objargsr.   r/   elemr3   r4   s                      r5   _build_ufunc_loop_body_objmoder?   ,   s    DFFE #in"5"55H 
	&	&   *88$9>9A5J J  	 	DLL	               
E&MMM (( E ESgkk',,s"3"3SX>>DDDDMM'++gll<88#(CC      ;s   ABBBc
                 ^    fd}
fd}t          |
|| ||||	          S )Nc                  @    fdt                    D             } | S )Nc                 f    g | ]-\  }}|                                         |                    .S  load_directr!   .0r3   r4   r&   s      r5   
<listcomp>z6build_slow_loop_body.<locals>.load.<locals>.<listcomp>O   E     7 7 7S# c!2!233 7 7 7    )r   )r-   r'   r&   r)   s    r5   r!   z"build_slow_loop_body.<locals>.loadN   s:    7 7 7 7!$Wf!5!57 7 7rJ   c                 Z                         |                                          d S N)store_directr!   )r/   r&   r(   r*   s    r5   r   z#build_slow_loop_body.<locals>.storeS   s+    l!;!;<<<<<rJ   r   r6   )r$   r%   r&   r'   r(   r)   r*   r+   r,   r   r!   r   s     `````     r5   build_slow_loop_bodyrP   L   s          
= = = = = = = "$wgv"%wi&)+ + + +rJ   c                     |                      |	          }                    |
||	          fd}fd}t          ||| ||	          S )Nc                      fdt                    D             } fdt          | j                  D             } | S )Nc                 f    g | ]-\  }}|                                         |                    .S rC   rD   rF   s      r5   rH   z5build_obj_loop_body.<locals>.load.<locals>.<listcomp>b   rI   rJ   c                 D    g | ]\  }}                     ||          S rC   )from_native_value)rG   vtenv_managerr,   s      r5   rH   z5build_obj_loop_body.<locals>.load.<locals>.<listcomp>e   s?     9 9 9Q ((A{;; 9 9 9rJ   )r   r   )r-   r'   r&   rX   r)   r,   r+   s    r5   r!   z!build_obj_loop_body.<locals>.load`   ss    7 7 7 7!$Wf!5!57 7 79 9 9 9 9 	779 9 9rJ   c                 `   t          j        |           }                    |d          5                      j        |           }|j        J                     |j                                                 	                    |            d d d            d S # 1 swxY w Y   d S r   )
r   is_not_nullif_thento_native_valuer   cleanuprM   valuer!   r<   )r/   r   nativer&   r(   r,   r+   r*   s      r5   r   z"build_obj_loop_body.<locals>.storei   s    #GV44 __U4_00 	! 	!**9+@&IIF>)))V\7<<+E+EFFFLL   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   A(B##B'*B')get_env_bodyget_env_managerr?   )r$   r%   r&   r'   r(   r)   r*   r+   r,   envptrr   env_bodyr!   r   rX   s     ```````     @r5   build_obj_loop_bodyrd   [   s    ##GV44H''Xv>>K         ! ! ! ! ! ! ! ! ! *$wg*0#w*3VUD D DrJ   c                 V    fd}fd}t          ||| ||||||	|
          S )Nc                  $    fdD             } | S )Nc                 :    g | ]}|                               S rC   )load_aligned)rG   r4   inds     r5   rH   z6build_fast_loop_body.<locals>.load.<locals>.<listcomp>~   s7     $ $ $ !!#&& $ $ $rJ   rC   )r-   r'   ri   s    r5   r!   z"build_fast_loop_body.<locals>.load}   s0    $ $ $ $"$ $ $rJ   c                 4                         |            d S rL   )store_aligned)r/   ri   r(   s    r5   r   z#build_fast_loop_body.<locals>.store   s    &#&&&&&rJ   rN   rO   )r$   r%   r&   r'   r(   r)   r*   r+   ri   r,   r   r!   r   s      ``   `    r5   build_fast_loop_bodyrl   {   st         
' ' ' ' ' ' "$wgv"%wi&)+ + + +rJ   c                 
   t          |t                    sJ t          j        d          }t          j        |          }t          j        |          }|                    t          j                  }	t          j        |	          }
t          j        t          j	                    ||
|
|g          }|
                                                    d          }|                    d          }|rF|j                            t          j        t          j        gt!          |j                  z            }n%|j                            |j        |j                  }t          j        |||          }|j                            d           t          j        ||d|j        z             }|j        \  }}}}d|_        d|_        d	|_        d
|_        t/          |                    d                    }|                    |j                  }|j        }|                    |                    |j        |                    }|                    |d          }g }t?          |j                  D ],\  }}|                     tC          ||||||                     -tC          ||||t!          |          |j                  }g }|"                    t          j        d          }|D ]B} tG          j$        ||	          }!|                     |!           |%                    ||!           CtG          j$        ||	          }"|%                    ||"           tF          j&        }#|D ]}$|'                    |#|$j(                  }#|)                    |          }%|r|%*                                }&tG          j+        |||	          5  tY          |||||||"||%||           ddd           n# 1 swxY w Y   |%-                    |&           |.                                 n|/                    |#          5 \  }'}(|'5  tG          j+        |||	          5 })ta          |||||||"||)j1        |%|           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |(5  tG          j+        |||	          5  te          |||||||"||%|
  
         ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |.                                 ~|3                    |           |4                    |            tk          |||j                  S )z
    Wrap the scalar function with a loop that iterates over the arguments

    Returns
    -------
    (library, env, name)
       ufunc_wrapper r   alwaysinlinez
__ufunc__.r   dimsstepsdataentry	loopcountr   intpNrN   r   )6
isinstancestrr   IntTypePointerTypeget_value_typer   ry   FunctionTypeVoidTypecodegencreate_librarycreate_ir_moduler   get_function_typer9   r:   r   r   Function
attributesr    r   r   append_basic_blockget_env_namefndescenvironmentr!   declare_env_globalmodule	enumerateappend	UArrayArgget_constantr   alloca_oncer   true_bitand_is_unit_stridedget_python_apir   	for_rangerd   r   ret_voidr   rl   indexrP   add_ir_moduleadd_linking_libraryr   )*r   r$   fnamer+   objmodecresbyte_t
byte_ptr_tbyte_ptr_ptr_tintp_t
intp_ptr_tfnty
wrapperlibwrapper_module	func_typer%   wrapperarg_argsarg_dims	arg_stepsarg_datar&   envnamer   rb   rw   r'   itypr(   r)   zero_pr*   unit_stridedr4   r,   r2   r   
is_stridedloops*                                             r5   build_ufunc_wrapperr      s    eS!!!!!Z]]F''J^J//N##EJ//F''J?2;==>:+5z+C D DD ""11/BBJ0044N 3%77NU^,s9>/B/BBD D		 %77!9>3 3	 ;~yu===DO'''k.$ty0HIIG.5l+Hh	8HMHMINHM227;;<<G ""4;//G

C\\'44W^WMMNNF XK88I FIN++ P P3i(Iq#NNOOOO GWh	3v;;)+ +C G
A..D  00qdA&w77LMM$%%%#L G G||L#2EFF""7++E   w	??? 	 	wWi  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	# __\** 	.K
   &w	GGG 4(wW$iU"                                  &w	GGG  (wW$i"                               	 	 	 	 	 	 	 	 	 	 	 	 	 	 	$ 	 ^,,,""7+++7<HHHHs   O((O,/O,3T9R Q=1R=RRRRTR	TR	T!S69SS6S##S6&S#'S6*T6S:	:T=S:	>TTTc                   ,    e Zd Zd Zd Zd Zd Zd ZdS )r   c                    || _         || _        || _        | j                             t          j        |          }| j                            |                    ||g                    }|                    |          }	| j        	                    ||	
                                          | _        | j                             |	          }
| j                             t          j        |
          | _        | j                            ||g          }| j                            |          | _        |                    d| j        | j                  | _        || _        d S )Nz==)r$   r&   fe_typer   r   ry   r!   gepget_data_typebitcast
as_pointerdataptrget_abi_sizeofabisizer"   icmp_unsignedr   )selfr$   r&   r   rt   r   r   offsetoffseted_args	data_typesizeofoffseted_steps               r5   __init__zUArrayArg.__init__   s$   **5:q99))'++dVH*E*EFF))'22	|++M,5,@,@,B,BD D,,Y77|00VDD((99L%%m44	&44T59\49 N  NrJ   c                     t          j        | j        | j        |          }| j                            | j        | j        |          S )zm
        Generic load from the given *byteoffset*.  load_aligned() is
        preferred if possible.
        )r   pointer_addr&   r   r$   unpack_valuer   )r   
byteoffsetptrs      r5   rE   zUArrayArg.load_direct  s:    
 !$,jII|((t|SIIIrJ   c                     | j                             | j        |g          }| j                            | j         | j        |          S rL   )r&   r   r   r$   r   r   )r   ri   r   s      r5   rh   zUArrayArg.load_aligned  s=     lt|cU33|((t|SIIIrJ   c                     t          j        | j        | j        |          }| j                            | j        | j        ||           d S rL   )r   r   r&   r   r$   
pack_valuer   )r   r^   r   r   s       r5   rM   zUArrayArg.store_direct  s@    !$,jIIdlE3GGGGGrJ   c                     | j                             | j        |g          }| j                            | j         | j        ||           d S rL   )r&   r   r   r$   r   r   )r   r^   ri   r   s       r5   rk   zUArrayArg.store_aligned  sC    lt|cU33dlE3GGGGGrJ   N)__name__
__module____qualname__r   rE   rh   rM   rk   rC   rJ   r5   r   r      sm          "J J JJ J JH H HH H H H HrJ   r   gufc                       e Zd Zd Zed             Zed             Zed             Zed             Zed             Z	ed             Z
d Zd	 Zd
 Zed             Zd Zd Zd ZdS )_GufuncWrapperc                     || _         || _        || _        || _        | j        j        t          j        k    | _        |rt          | j                   nt                      | _        t          |          | _        dS )a,  
        The *is_parfors* argument is a boolean that indicates if the GUfunc
        being built is to be used as a ParFors kernel. If True, it disables
        the caching on the wrapper as a separate unit because it will be linked
        into the caller function and cached along with it.
        )py_funcN)r   r   sinsoutr+   r   r   r9   is_objectmodeGufWrapperCacher   cachebool
is_parfors)r   r   r   r   r   r   r   s          r5   r   z_GufuncWrapper.__init__&  so     		!^75>I0odl;;;;$-KK 	
z**rJ   c                     | j         j        S rL   )r   r   r   s    r5   r   z_GufuncWrapper.library6  s    y  rJ   c                     | j         j        S rL   )r   target_contextr   s    r5   r$   z_GufuncWrapper.context:  s    y''rJ   c                     | j         j        S rL   )r$   r   r   s    r5   r   z_GufuncWrapper.call_conv>  s    |%%rJ   c                     | j         j        S rL   )r   r+   r   s    r5   r+   z_GufuncWrapper.signatureB  s    y""rJ   c                     | j         j        S rL   )r   r   r   s    r5   r   z_GufuncWrapper.fndescF  s    yrJ   c                     | j         j        S rL   )r   r   r   s    r5   r   z_GufuncWrapper.envJ  s    y$$rJ   c                 B   t          j        d          }t          j        |          }t          j        |          }| j                            t
          j                  }t          j        |          }t          j        t          j                    ||||g          }|S )Nrn   )	r   r|   r}   r$   r~   r   ry   r   r   )r   r   r   r   r   r   r   s          r5   _wrapper_function_typez%_GufuncWrapper._wrapper_function_typeN  s    A^F++

33,,UZ88^F++
r{}}~z/9:/G H HrJ   c                   ! | j                             t          j                  }|                                 }|                    d          }| j                            | j        j	        | j        j
                  }| j        j        }t          j        |||          }|j                            d           t          j        |||          }	d|	_        |	j        \  }
}}}d|
_        d|_        d|_        d|_        t'          |	                    d	                    }|                    |d
          }| j                             |          }t/                      }| j        | j        fD ]}|D ]}|t/          |          z  }i }| j        D ]}|D ]}||vrt5          |          ||<   i }|                                D ]X\  }}|                    |                    || j                             t          j        |dz             g                    ||<   Yg }t5          | j                  t5          | j                  z   }t=          t?          | j         j        | j        | j        z                       D ]K\  }\  }}tC          | j         ||
||||||	  	        }|t5          |          z  }|"                    |           L|                    d          }| #                    ||           tI          j%        |||          5 !!fd|D             }| &                    ||||          \  }} tI          j'        || |           ddd           n# 1 swxY w Y   |(                    |           |)                    |           | *                    ||           |+                                 |,                    |           |-                    | j.                   dS )z
        The LLVM IRBuilder code to create the gufunc wrapper.
        The *library* arg is the CodeLibrary to which the wrapper should
        be added.  The *name* arg is the name of the wrapper function being
        created.
        _gufunc_wrapperrq   rr   weak_odrr   rs   rt   ru   rv   rw      z.returnrx   c                 D    g | ]}|                     j                  S rC   )get_array_at_offsetr   )rG   ar   s     r5   rH   z1_GufuncWrapper._build_wrapper.<locals>.<listcomp>  s)    FFF!A))$*55FFFrJ   N)/r$   r~   r   ry   r   r   r   r   r   restypeargtypesllvm_func_namer   r   r   r    linkager   r   r   r   r!   r   setr   r   r:   itemsr   r   r   r   r+   
GUArrayArgr   gen_prologuer   r   gen_loop_bodycbranch_or_continuebranchposition_at_endgen_epiloguer   r   r   r   )"r   r   r   r   r   r   r   r   r%   r   r   r   r   r   r&   rw   r,   unique_symsgrpsymssym_mapssym_dimr   r'   step_offsetr   symr4   bbreturnr   	innercallerrorr   s"                                    @r5   _build_wrapperz_GufuncWrapper._build_wrapperY  sZ    ,,UZ88**,, 112CDDN44T[5H59[5IK K	*{>95AAAN++++ndD99 %29,/(Ix 	G66w??@@LLL<<	++G44 eeHdi( 	) 	)C ) )s4yy() H 	. 	.D . .G##!$WGAJ. MMOO 	@ 	@DAq gkk(37<3L3L6;j67!e4= 4= 3>'? '? @ @GAJJ $(mmc$)nn4&s4>+>+/8di+?(A (A B B 	 	MAzST\7H&;S'K KC3s88#KMM#--i88 	'5))) w	??? 	B4FFFFvFFFD#11'5$MMIu'AAA		B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	x   ))) 	'5))) 	n---##DL11111s   A MMMc                 &   | j         rP| j                                                            t	          |                     }|                     ||           n| j                            | j        j	        | j        j
                  }|| j                                                            t	          |                     }|                                 |                     ||           | j                            | j        j	        |           |S rL   )r   r$   r   r   r{   r	  r   load_overloadr   r+   r   enable_object_cachingsave_overloadr   wrapper_namer   s      r5   _compile_wrapperz_GufuncWrapper._compile_wrapper  s    ? 	J--//>>s4yyIIJ
L9999 11	#TY%= J !!\1133BB3t99MM
00222##J===
(()<jIIIrJ   c                 x    d| j         j        z   }|                     |          }t          || j        |          S )Nz__gufunc__.r   )r   mangled_namer  r   r   r  s      r5   buildz_GufuncWrapper.build  sD    $t{'??**<88
DH<
 
 
 	
rJ   c                    | j                             ||| j        j        | j        j        |          \  }}|                    |j        d          5  |                                }| j        j         	                    |||           |
                    |           d d d            n# 1 swxY w Y   |j        |j        fS )NFr   )r   r   r+   r   r   r[   is_errorr   r$   r   r   r#   )r   r&   r,   r%   r   r.   r/   r2   s           r5   r   z_GufuncWrapper.gen_loop_body  s    55T4>5t~7J  __V_U_;; 	# 	#""$$CL"..wvFFFc"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#
 {FO++s   AB))B-0B-c                     d S rL   rC   r   r&   r,   s      r5   r   z_GufuncWrapper.gen_prologue      rJ   c                     d S rL   rC   r  s      r5   r   z_GufuncWrapper.gen_epilogue  r  rJ   N)r   r   r   r   propertyr   r$   r   r+   r   r   r   r	  r  r	   r  r   r   r   rC   rJ   r5   r   r   %  s?       + + +  ! ! X! ( ( X( & & X& # # X#     X  % % X%	 	 	R2 R2 R2h  0 
 
 

, 
, 
,      rJ   r   c                        e Zd Zd Zd Zd ZdS )_GufuncObjectWrapperc                 L    t          | j        |||| j        |          \  }}||fS rL   )_prepare_call_to_object_moder$   r+   )r   r&   r,   r%   r   r  r  s          r5   r   z"_GufuncObjectWrapper.gen_loop_body  s6    78?8<8<> >	5 %rJ   c                 8    |                                 | _        d S rL   )r   r2   r  s      r5   r   z!_GufuncObjectWrapper.gen_prologue  s    ##%%rJ   c                 :    |                     | j                   d S rL   )r   r2   r  s      r5   r   z!_GufuncObjectWrapper.gen_epilogue  s    $(#####rJ   N)r   r   r   r   r   r   rC   rJ   r5   r  r    sA             & & &$ $ $ $ $rJ   r  c                     |j         }|j        t          j        k    rt          nt
          } || |||||                                          S )N)r   )r+   r   r   r9   r  r   r  )r   r   r   r   r   r   r+   wrapclss           r5   build_gufunc_wrapperr#    sZ    I'5>99 $#"  7sD%J  eggrJ   c           
      h   |j         }|                    d          }|                     t          j                  }|                     t          j                  }	t          j        |	          }
|                     t          j                  }|                     t          j	                  }t          j
        |||
|
|||g          }t          j        ||d          }t          j        |t          j        d          d          }|                    t          j        |           g }g }t#          t%          ||j                            D ]\  }\  }}t          j        ||d          }|                    |           t+          |t          j                  r&|                     |          } || ||          }t1          |d	          }t1          ||j                  }|                    |                    d
          ||g          }|                    |                    d          ||g          }|                    |j        |          }t=          j        tA          |j                            }t1          ||j!                  }t1          ||j"                  }|#                    |||||||g          } n|$                    ||          } |                    | |           |                    |            t          j%        ||           }!|                    |!|           t          j&        ||!|           t          j	        gtO          |          z  }"| j(        )                    ||t          j	        |"|          \  }#}$|                    |#j*        |           |+                    |$           |,                    |           |-                    |           |D ]*}|+                    |.                    |                     +|#j/        }%|%|.                    |          fS )Nzufunc.core.returnnumba_ndarray_newr   r  rq   T)zfill)r^   r   shapestrides)0r   r   r~   r   int32ry   r   r}   voidptrr9   r   r   get_or_insert_functionr   r|   r   r   r   r   r   r   rz   Array
make_arrayr   ndimr   _get_ptr_by_namer   ru   npdtyper{   numitemsizecallrU   is_nullr   r:   r   r   r  r<   r   r   r!   r#   )&r$   r&   r,   r%   r+   r   modbb_core_returnll_intll_intpll_intp_ptr
ll_voidptrll_pyobjr   fn_array_newerror_pointerobject_argsobject_pointersr   argargtyobjptraryclsarrayr   ndrs   r(  ru   r1  type_numr3  objobj_is_null
object_sigr.   r/   r  s&                                         r5   r  r    s   
.C//0CDDN ##EK00F$$UZ00G.))K''66J%%en55H?8fk&1:&,f&6 7 7D 1#t2EG GL 'AWMMMMMM'"M222 KO$Sy~%>%>?? %J %J<C$WhdCCCv&&&eU[)) 	6 ''..FF7G3777EFA&&D &%*--B;;u55g>>tMMDkk%"8"8"C"C#',0 0G??5:z::DHS--..E  	22H77H ,,|b$.6.B C CCC ))%55Cc6"""3ogs33k=111#G[.IIII .!C$4$44J&44u~z NFF MM&/=111 
LLNN>"""N+++ " + +W\\&))****Igll=1111rJ   c                       e Zd Zd Zd ZdS )r   c
           	        	 || _         || _        |                    t          j        |          }
|                    |                    ||
gd          d          }|| _        |                    ||
gd          }|                    |          }t          |t          j	                  r| }t          |          |j        k    rDt          |          dk    r|j        dk    rn%t          d                    |dz                       |j        }	fd|D             }g }t          |          D ]f}|                    ||                    t          j        ||z             gd	          }|                    |          }|                    |           g|rt           nt"          } ||j        |||||
          | _        d S |r&t          d                    ||dz                       t)          ||          | _        d S )Nzdata.ptrrq   ru   zcore.step.ptrr   r   z.type and shape signature mismatch for arg #{0}c                      g | ]
}|         S rC   rC   )rG   r  r  s     r5   rH   z'GUArrayArg.__init__.<locals>.<listcomp>{  s    ...AWQZ...rJ   zstep.ptrr1  r.  	core_step	as_scalarr'  r(  z2scalar type {0} given for non scalar argument #{1}r1  stride)r$   r&   r   r   ry   r!   r   ru   rz   r,  r:   r.  	TypeErrorformatranger   _ArrayAsScalarArgLoader_ArrayArgLoaderr1  _loader_ScalarArgLoader)r   r$   r&   r   rt   r   r  r   r   r  r   ru   core_step_ptrrO  rP  r.  r'  r(  jstepptrr"   ldclss            `            r5   r   zGUArrayArg.__init__\  sA    %%ej!44||GKKvhZKHH!'  ) )	EF8/JJLL//	c5;'' *	I I 4yyCH$$t99>>ch!mm # %++16!a%==: : : 8D.......EG4[[ % %!++e'.';';EJ<G!O(M (M 'N+5 & 7 7 ||G,,t$$$$ "*,,)  !5sy&*+4+4',)02 2 2DLLL  D !006sAE0B0BD D D+#iHHHDLLLrJ   c                 \    | j                             | j        | j        | j        |          S )N)r$   r&   ru   ri   )rX  r!   r$   r&   ru   )r   ri   s     r5   r   zGUArrayArg.get_array_at_offset  s0    |  t|&*iS ! : : 	:rJ   N)r   r   r   r   r   rC   rJ   r5   r   r   [  s6        9I 9I 9Iv: : : : :rJ   r   c                       e Zd ZdZd Zd ZdS )rY  z
    Handle GFunc argument loading where a scalar type is used in the core
    function.
    Note: It still has a stride because the input to the gufunc can be an array
          for this argument.
    c                 "    || _         || _        d S rL   rQ  )r   r1  rR  s      r5   r   z_ScalarArgLoader.__init__  s    
rJ   c                    |                     ||                    || j                  g          }|                    ||                    | j                                                            }|                    |          S rL   )r   mulrR  r   r   r1  r   r!   )r   r$   r&   ru   ri   dptrs         r5   r!   z_ScalarArgLoader.load  sp    {{4'++c4;"?"?!@AAt&44TZ@@KKMMO O||D!!!rJ   N)r   r   r   __doc__r   r!   rC   rJ   r5   rY  rY    s<           " " " " "rJ   rY  c                   $    e Zd ZdZd Zd Zd ZdS )rW  zD
    Handle GUFunc argument loading where an array is expected.
    c                 Z    || _         || _        || _        || _        || _        || _        d S rL   rN  )r   r1  r.  rO  rP  r'  r(  s          r5   r   z_ArrayArgLoader.__init__  s0    
	""
rJ   c           
      F   t          j        | j        | j        d          }|                    |          } |||          }t          j        |||                    | j        |                    }| 	                    ||          \  }	}
|
                    |                    | j                            }|                    ||                    ||j        j                  |	|
|                    t           j        |          d            |                                S )NA)r1  r.  layout)ru   r'  r(  r3  meminfo)r   r,  r1  r.  r-  r   r   rb  rO  _shape_and_stridesr   r   populate_arrayr   ru   typer   ry   	_getvalue)r   r$   r&   ru   ri   arytyprD  rE  offseted_datar'  r(  r3  s               r5   r!   z_ArrayArgLoader.load  s   4:DIcJJJ##F++w((+G,0,3KK8;-= -=> >
 00'BBw))'*?*?
*K*KLLu$+OOM49JO%E %E%*'.(/(<(<UZ=E)G )G'+ 	 	- 	- 	-    rJ   c                 r    t          j        || j                  }t          j        || j                  }||fS rL   )r   
pack_arrayr'  r(  )r   r$   r&   r'  r(  s        r5   rk  z"_ArrayArgLoader._shape_and_strides  s4    "7DJ77$Wdl;;g~rJ   N)r   r   r   rd  r   r!   rk  rC   rJ   r5   rW  rW    sK           ! ! !0    rJ   rW  c                       e Zd ZdZd ZdS )rV  z
    Handle GUFunc argument loading where the shape signature specifies
    a scalar "()" but a 1D array is used for the type of the core function.
    c                     |                     t          j        d          }|                     t          j        d          }t          j        ||g          }t          j        ||g          }||fS )Nr   r   )r   r   ry   r   rr  )r   r$   r&   oner   r'  r(  s          r5   rk  z*_ArrayAsScalarArgLoader._shape_and_strides  sb    ""5:q11##EJ22"7SE22$Wtf55g~rJ   N)r   r   r   rd  rk  rC   rJ   r5   rV  rV    s-         
    rJ   rV  )#collectionsr   numpyr0  llvmlite.irr   r   llvmliter   
numba.corer   r   numba.core.compiler_lockr	   numba.core.cachingr
   r   r   r6   r?   rP   rd   rl   r   objectr   r   r   r  r#  r  r   rY  rW  rV  rC   rJ   r5   <module>r~     s   " " " " " "     + + + + + + + +       % % % % % % % % 9 9 9 9 9 9 < < < < < < < < 
?,F,F,FGG  8  @+ + +D D D@+ + +lI lI lI^&H &H &H &H &H &H &H &HR %$U++x x x x xV x x xv$ $ $ $ $> $ $ $"  ]2 ]2 ]2@>: >: >: >: >: >: >: >:B" " " " "v " " "(( ( ( ( (f ( ( (V    o     rJ   