
    xKgCj                     P   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"y)!    )
namedtupleN)Constant	IRBuilder)ir)typescgutils)global_compiler_lock)make_library_cache	NullCache_wrapper_infolibraryenvnamec                     |        }|j                   j                  |||	j                  |	j                  |      \  }}|j	                  |j
                  d      5 \  }}|5   ||       d d d        |5  |
j                         }|j                   j                  ||
|       |
j                  |       d d d        d d d        t        ||      D ]@  \  }}|j                  |j                  |j                  |      |j                        |       B |j                  |j                  |j                  |      |j                        |       |j                  S # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w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                       [/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/np/ufunc/wrappers.py_build_ufunc_loop_bodyr6      s4   FE &&44Wd5>5J5J5>^^ULNFF
 
d	37Hx&M ""$C))'5&Ac"  
4 (Sgkk',,s"3SXX>D ) MM'++gll<8#((C  ;; UX 
4	3s<   E1!	E*
E14?E%3E1E"	E1%E.	*E11E:c                 z    |        }t         j                  gt        |	j                        z  }|j	                  d      5  |j
                  j                  ||t         j                  ||      \  }}|D ]  }|j                  |        	 d d d         |       t        ||      D ]@  \  }}|j                  |j                  |j                  |      |j                        |       B |j                  |j                  |j                  |      |j                        |       j                  S # 1 sw Y   xY w)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    FE #inn"55H 
	& **88$9>9A5J DLL  
' 
&M (Sgkk',,s"3SXX>D ) MM'++gll<8#((C  ;;' 
'	&s   A	D11D:c
                 V    fd}
fd}t        |
|| ||||	      S )Nc            	          t              D  cg c]%  \  } }|j                  j                  |             ' }} }|S c c}} w N)r   load_directr!   )r3   r4   r-   r'   r&   r)   s      r5   r!   z"build_slow_loop_body.<locals>.loadN   sJ    !$Wf!57!5XS# c!23!5 	 77s   *A c                 H    j                  | j                               y rB   )store_directr!   )r/   r&   r(   r*   s    r5   r   z#build_slow_loop_body.<locals>.storeS   s    l!;<    r   r6   )r$   r%   r&   r'   r(   r)   r*   r+   r,   r   r!   r   s     `````     r5   build_slow_loop_bodyrI   L   s6    
= "$wgv"%wi&)+ +rF   c                     | j                  |	      }j                  |
||	      fd}fd}t        ||| ||	      S )Nc            	      
   t              D  cg c]%  \  } }|j                  j                  |             ' }} }t        |
j                        D cg c]  \  }}	j	                  ||       }}}|S c c}} w c c}}w rB   )r   rC   r!   r   from_native_value)r3   r4   r-   vtr'   r&   env_managerr)   r,   r+   s        r5   r!   z!build_obj_loop_body.<locals>.load`   s     "%Wf!57!5XS# c!23!5 	 7 !	797TQ ((A{;7 	 979s   *A9A?c                 N   t        j                  |       }j                  |d      5  j                  j                  |       }|j
                  J j                  |j                  j                               j                  |        d d d        y # 1 sw Y   y xY wr   )
r   is_not_nullif_thento_native_valuer   cleanuprE   valuer!   r<   )r/   r   nativer&   r(   r,   r+   r*   s      r5   r   z"build_obj_loop_body.<locals>.storei   s    ##GV4 __U4_0**9+@+@&IF>>)))V\\7<<+EFLL  100s   A'BB$)get_env_bodyget_env_managerr?   )r$   r%   r&   r'   r(   r)   r*   r+   r,   envptrr   env_bodyr!   r   rO   s     ```````     @r5   build_obj_loop_bodyr[   [   sh    ##GV4H''Xv>K ! ! *$wg*0#w*3VUD DrF   c                 N    fd}fd}t        ||| ||||||	|
      S )Nc                  N    D  cg c]  } | j                         }} |S c c} w rB   )load_aligned)r4   r-   r'   inds     r5   r!   z"build_fast_loop_body.<locals>.load}   s8    "$"S !!#&" 	 $$s   "c                 *    j                  |        y rB   )store_aligned)r/   r_   r(   s    r5   r   z#build_fast_loop_body.<locals>.store   s    &#&rF   rG   rH   )r$   r%   r&   r'   r(   r)   r*   r+   r_   r,   r   r!   r   s      ``   `    r5   build_fast_loop_bodyrb   {   s6    
' "$wgv"%wi&)+ +rF   c                 |
   t        |t              sJ t        j                  d      }t        j                  |      }t        j                  |      }|j                  t        j                        }	t        j                  |	      }
t        j                  t        j                         ||
|
|g      }|j                         j                  d      }|j                  d      }|rP|j                  j                  t        j                  t        j                  gt!        |j"                        z        }n0|j                  j                  |j$                  |j"                        }t        j&                  |||      }|j(                  j+                  d       t        j&                  ||d|j,                  z         }|j"                  \  }}}}d|_        d|_        d	|_        d
|_        t/        |j1                  d            }|j3                  |j4                        }|j6                  }|j9                  |j;                  |j<                  |            }|j9                  |d      }g }t?        |j"                        D ]$  \  }}|jA                  tC        ||||||             & tC        ||||t!        |      |j$                        }g }|jE                  t        j                  d      }|D ];  } tG        jH                  ||	      }!|jA                  |!       |jK                  ||!       = tG        jH                  ||	      }"|jK                  ||"       tF        jL                  }#|D ]  }$|jO                  |#|$jP                        }#  |jS                  |      }%|rh|%jU                         }&tG        jV                  |||	      5  tY        |||||||"||%||       ddd       |%j[                  |&       |j]                          n|j_                  |#      5 \  }'}(|'5  tG        jV                  |||	      5 })ta        |||||||"||)jb                  |%|       ddd       ddd       |(5  tG        jV                  |||	      5  te        |||||||"||%|
       ddd       ddd       ddd       |j]                          ~|jg                  |       |ji                  |        tk        |||j,                        S # 1 sw Y   !xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)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   intpNrG   r   )6
isinstancestrr   IntTypePointerTypeget_value_typer   ro   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_ranger[   r   ret_voidr   rb   indexrI   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   rY   rm   r'   itypr(   r)   zero_pr*   unit_stridedr4   r,   r2   r   
is_stridedloops*                                             r5   build_ufunc_wrapperr      st    eS!!!ZZ]F'J^^J/N##EJJ/F'J??2;;=>:+5z+C DD "11/BJ004N%%77NNU^^,s9>>/BBD	 %%77!!9>>3	 ;;~yu=DOO'kk.$tyy0HIG.5ll+Hh	8HMHMINHM227;<G ""4;;/G


C\\'44W^^WMNF XK8I FINN+3i(Iq#NO , GWh	3v;))+C G

A.D0qdA 
 &&w7LMM$%##L||L#2E2EF  ""7+E w	?wWi @
 	# __\*.K
 &&w	G4(wW$iU" H ! &&w	G(wW$i" H  +$ 	 ^,""7+7<<HHC @? HG ! HG  +*sx    S5T2T0!TT
T2#T&<TT&T25S?TTT	T2T#T&&T/	+T22T;c                   *    e Zd Zd Zd Zd Zd Zd Zy)r   c                    || _         || _        || _        | j                   j                  t        j
                  |      }| j                  j                  |j                  ||g            }|j                  |      }	| j                  j                  ||	j                               | _        | j                   j                  |	      }
| j                   j                  t        j
                  |
      | _        | j                  j                  ||g      }| j                  j                  |      | _        |j                  d| j                  | j                        | _        || _        y )Nz==)r$   r&   fe_typer   r   ro   r!   gepget_data_typebitcast
as_pointerdataptrget_abi_sizeofabisizer"   icmp_unsignedr   )selfr$   r&   r   rj   r   r   offsetoffseted_args	data_typesizeofoffseted_steps               r5   __init__zUArrayArg.__init__   s   **5::q9))'++dVH*EF))'2	||++M,5,@,@,BD,,Y7||00VD((9LL%%m4	&44T59\\499 NrF   c                     t        j                  | 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   rC   zUArrayArg.load_direct  sA    
 !!$,,jI||((t||SIIrF   c                     | j                   j                  | j                  |g      }| j                  j	                  | j                   | j
                  |      S rB   )r&   r   r   r$   r   r   )r   r_   r   s      r5   r^   zUArrayArg.load_aligned  sA     llt||cU3||((t||SIIrF   c                     t        j                  | j                  | j                  |      }| j                  j                  | j                  | j                  ||       y rB   )r   r   r&   r   r$   
pack_valuer   )r   rU   r   r   s       r5   rE   zUArrayArg.store_direct  s>    !!$,,jIdllE3GrF   c                     | j                   j                  | j                  |g      }| j                  j	                  | j                   | j
                  ||       y rB   )r&   r   r   r$   r   r   )r   rU   r_   r   s       r5   ra   zUArrayArg.store_aligned  s>    llt||cU3dllE3GrF   N)__name__
__module____qualname__r   rC   r^   rE   ra    rF   r5   r   r      s    "JJHHrF   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y)_GufuncWrapperc                    || _         || _        || _        || _        | j                  j
                  t        j                  k(  | _        |rt        | j                         n	t               | _        t        |      | _        y)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__&  sd     		!^^775>>I &dll;$-K 	
z*rF   c                 .    | j                   j                  S rB   )r   r   r   s    r5   r   z_GufuncWrapper.library6  s    yy   rF   c                 .    | j                   j                  S rB   )r   target_contextr   s    r5   r$   z_GufuncWrapper.context:  s    yy'''rF   c                 .    | j                   j                  S rB   )r$   r   r   s    r5   r   z_GufuncWrapper.call_conv>  s    ||%%%rF   c                 .    | j                   j                  S rB   )r   r+   r   s    r5   r+   z_GufuncWrapper.signatureB  s    yy"""rF   c                 .    | j                   j                  S rB   )r   r   r   s    r5   r   z_GufuncWrapper.fndescF  s    yyrF   c                 .    | j                   j                  S rB   )r   r   r   s    r5   r   z_GufuncWrapper.envJ  s    yy$$$rF   c                 X   t        j                  d      }t        j                  |      }t        j                  |      }| j                  j	                  t
        j                        }t        j                  |      }t        j                  t        j                         ||||g      }|S )Nrd   )	r   rr   rs   r$   rt   r   ro   ru   rv   )r   r   r   r   r   r   r   s          r5   _wrapper_function_typez%_GufuncWrapper._wrapper_function_typeN  s|    A^^F+

3,,UZZ8^^F+
r{{}~z/9:/G HrF   c                    | j                   j                  t        j                        }| j	                         }|j                  d      }| j                  j                  | j                  j                  | j                  j                        }| j                  j                  }t        j                  |||      }|j                  j                  d       t        j                  |||      }	d|	_        |	j"                  \  }
}}}d|
_        d|_        d|_        d|_        t'        |	j)                  d	            }|j+                  |d
      }| j                   j-                  |      }t/               }| j0                  | j2                  fD ]  }|D ]  }|t/        |      z  }  i }| j0                  D ]  }|D ]  }||vst5        |      ||<     i }|j7                         D ]U  \  }}|j+                  |j9                  || j                   j;                  t        j                  |dz         g            ||<   W g }t5        | j0                        t5        | j2                        z   }t=        t?        | j@                  j"                  | j0                  | j2                  z               D ]D  \  }\  }}tC        | j                   ||
||||||	      }|t5        |      z  }|jE                  |       F |j)                  d      }| jG                  ||       tI        jJ                  |||      5 }|D cg c]  }|jM                  |jN                         } }| jQ                  ||||       \  }!}"tI        jR                  ||"|       ddd       |jU                  |       |jW                  |       | jY                  ||       |j[                          |j]                  |       |j_                  | j`                         yc c}w # 1 sw Y   xY w)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_wrapperrg   rh   weak_odrr   ri   rj   rk   rl   rm      z.returnrn   N)1r$   rt   r   ro   r   ry   r   rz   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   get_array_at_offsetr   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&   rm   r,   unique_symsgrpsymssym_mapssym_dimr   r'   step_offsetr   symr4   bbreturnr   ar   	innercallerrors#                                      r5   _build_wrapperz_GufuncWrapper._build_wrapperY  s    ,,UZZ8**, 112CDNN44T[[5H5H59[[5I5IK	**{{>95AN+++ndD9 %29,,/(Ix 	G66w?@LLL<	++G4 eHHdii(Cs4y(  ) HHDG#!$WGAJ  
 MMODAq gkk(37<<3L3L6;jj67!e4= 3>'? @GAJ $ $((mc$))n4&s4>>+>+>+/88dii+?(A BMAzST\\7H&;S'KC3s8#KMM#B --i8 	'5) w	?4?EFv!A))$**5vDF#11'5$MIu''A	 @ 	x ) 	'5) 	n-##DLL1 G @?s   -P2"O=0P=PPc                 >   | j                   rF| j                  j                         j                  t	        |             }| j                  ||       |S | j                  j                  | j                  j                  | j                  j                        }|| j                  j                         j                  t	        |             }|j                          | j                  ||       | j                  j                  | j                  j                  |       |S rB   )r   r$   rw   rx   rq   r   r   load_overloadr   r+   r   enable_object_cachingsave_overloadr   wrapper_namer   s      r5   _compile_wrapperz_GufuncWrapper._compile_wrapper  s    ??--/>>s4yIJ
L9   11		##TYY%=%=J !!\\113BB3t9M
002##J=

(()<)<jIrF   c                     d| j                   j                  z   }| j                  |      }t        || j                  |      S )Nz__gufunc__.r   )r   mangled_namer  r   r   r  s      r5   buildz_GufuncWrapper.build  s>    $t{{'?'??**<8
DHH<
 	
rF   c                    | j                   j                  ||| j                  j                  | j                  j                  |      \  }}|j                  |j                  d      5  |j                         }| j                  j                   j                  |||       |j                  |       d d d        |j                  |j                  fS # 1 sw Y   !xY w)NFr   )r   r   r+   r   r   rR   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>>55t~~7J7J __V__U_;""$CLL""..wvFc" <
 {{FOO++ <;s   (A	CCc                      y rB   r   r   r&   r,   s      r5   r   z_GufuncWrapper.gen_prologue      rF   c                      y rB   r   r  s      r5   r   z_GufuncWrapper.gen_epilogue  r  rF   N)r   r   r   r   propertyr   r$   r   r+   r   r   r   r   r  r	   r	  r   r   r   r   rF   r5   r   r   %  s    +  ! ! ( ( & & # #     % %	R2h0 
 

,rF   r   c                       e Zd Zd Zd Zd Zy)_GufuncObjectWrapperc                 X    t        | j                  |||| j                  |      \  }}||fS rB   )_prepare_call_to_object_moder$   r+   )r   r&   r,   r%   r   r   r   s          r5   r   z"_GufuncObjectWrapper.gen_loop_body  s5    78?8<8<>	5 %rF   c                 .    |j                         | _        y rB   )r   r2   r  s      r5   r   z!_GufuncObjectWrapper.gen_prologue  s    ##%rF   c                 :    |j                  | j                         y rB   )r   r2   r  s      r5   r   z!_GufuncObjectWrapper.gen_epilogue  s    $((#rF   N)r   r   r   r   r   r   r   rF   r5   r  r    s     &$rF   r  c                     |j                   }|j                  t        j                  k(  rt        nt
        } || |||||      j                         S )N)r   )r+   r   r   r9   r  r   r	  )r   r   r   r   r   r   r+   wrapclss           r5   build_gufunc_wrapperr    sM    I''5>>9 $"  sD%JegrF   c           
         |j                   }|j                  d      }| j                  t        j                        }| j                  t        j
                        }	t        j                  |	      }
| j                  t        j                        }| j                  t        j                        }t        j                  |||
|
|||g      }t        j                  ||d      }t        j                  |t        j                  d      d      }|j                  t        j                   |       g }g }t#        t%        ||j&                              D ]  \  }\  }}t        j                  ||d      }|j)                  |       t+        |t        j,                        r| j/                  |      } || ||      }t1        |d	      }t1        ||j2                        }|j5                  |j7                  d
      ||g      }|j5                  |j7                  d      ||g      }|j9                  |j:                  |      }t=        j>                  tA        |j>                              }t1        ||jB                        }t1        ||jD                        }|jG                  |||||||g      } n|jI                  ||      } |j                  | |       |j)                  |        t        jJ                  ||       }!|j                  |!|       t        jL                  ||!|        t        j                  gtO        |      z  }"| jP                  jS                  ||t        j                  |"|      \  }#}$|j                  |#jT                  |       |jW                  |$       |jY                  |       |j[                  |       |D ]"  }|jW                  |j]                  |             $ |#j^                  }%|%|j]                  |      fS )Nzufunc.core.returnnumba_ndarray_newr   r   rg   T)zfill)rU   r   shapestrides)0r   r}   rt   r   int32ro   r   rs   voidptrr9   ru   r   get_or_insert_functionr   rr   r   r   r   r   r   r   rp   Array
make_arrayr   ndimr   _get_ptr_by_namer   rk   npdtyperq   numitemsizecallrL   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   ndri   r  rk   r'  type_numr)  objobj_is_null
object_sigr.   r/   r   s&                                         r5   r  r    s\   
..C//0CDN ##EKK0F$$UZZ0G..)K''6J%%enn5H??8fk&1:&,f&6 7D 11#t2EGL ''AWMMMM'""M2 KO$Sy~~%>?<C$$WhdCv&eU[[) ''.F7G37EFA&D &%**-B;;u55g>tMDkk%"8"8"C#',0G??5::z:DHHS-.E  		2H7H ,,|b$.6.B CC ))%5Cc6"3oogs3k=1##G[.IK @P ..!C$44J&&44u~~zNFF MM&//=1 
LLNN>"N+ "W\\&)* " Igll=111rF   c                       e Zd Zd Zd Zy)r   c
           	         || _         || _        |j                  t        j                  |      }
|j                  |j                  ||
gd      d      }|| _        |j                  ||
gd      }|j                  |      }t        |t        j                        r
| }t        |      |j                  k7  r;t        |      dk(  r|j                  dk(  rnt        dj                  |dz               |j                  }|D cg c]  }|	|   	 }}g }t        |      D ]Z  }|j                  ||j                  t        j                  ||z         gd      }|j                  |      }|j                  |       \ |rt         nt"        } ||j$                  |||||	      | _        y |rt        d
j                  ||dz               t)        ||      | _        y c c}w )Nzdata.ptrrg   rk   zcore.step.ptrr   r   z.type and shape signature mismatch for arg #{0}zstep.ptrr'  r$  	core_step	as_scalarr  r  z2scalar type {0} given for non scalar argument #{1}r'  stride)r$   r&   r   r   ro   r!   r   rk   rp   r"  r:   r$  	TypeErrorformatranger   _ArrayAsScalarArgLoader_ArrayArgLoaderr'  _loader_ScalarArgLoader)r   r$   r&   r   rj   r   r   r   r   r   r   rk   core_step_ptrrD  rE  r$  r   r  r  jstepptrr"   ldclss                          r5   r   zGUArrayArg.__init__\  s    %%ejj!4||GKKvhZKH!'  )	EF8/JLL/	c5;;' I 4yCHH$t9>chh!m # %++16!a%=: : 88D)-.AWQZE.G4[!++e'.';';EJJ<G!O(M 'N+5 & 7 ||G,t$ ! " -)  !syy&*+4+4',)02DL  !006sAE0BD D+#iHDL5 /s   Gc                 |    | j                   j                  | j                  | j                  | j                  |      S )N)r$   r&   rk   r_   )rM  r!   r$   r&   rk   )r   r_   s     r5   r   zGUArrayArg.get_array_at_offset  s3    ||  t||&*iiS ! : 	:rF   N)r   r   r   r   r   r   rF   r5   r   r   [  s    9Iv:rF   r   c                       e Zd ZdZd Zd Zy)rN  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                      || _         || _        y rB   rF  )r   r'  rG  s      r5   r   z_ScalarArgLoader.__init__  s    
rF   c                     |j                  ||j                  || j                        g      }|j                  ||j	                  | j
                        j                               }|j                  |      S rB   )r   mulrG  r   r   r'  r   r!   )r   r$   r&   rk   r_   dptrs         r5   r!   z_ScalarArgLoader.load  s_    {{4'++c4;;"?!@At&44TZZ@KKMO||D!!rF   N)r   r   r   __doc__r   r!   r   rF   r5   rN  rN    s    "rF   rN  c                   "    e Zd ZdZd Zd Zd Zy)rL  zD
    Handle GUFunc argument loading where an array is expected.
    c                 X    || _         || _        || _        || _        || _        || _        y rB   rC  )r   r'  r$  rD  rE  r  r  s          r5   r   z_ArrayArgLoader.__init__  s,    
	""
rF   c           
      @   t        j                  | j                  | j                  d      }|j	                  |      } |||      }t        j                  |||j                  | j                  |            }| j                  ||      \  }	}
|j                  |j                  | j                              }|j                  ||j                  ||j                  j                        |	|
|j!                  t         j"                  |      d        |j%                         S )NA)r'  r$  layout)rk   r  r  r)  meminfo)r   r"  r'  r$  r#  r   r   rW  rD  _shape_and_stridesr   r   populate_arrayr   rk   typer   ro   	_getvalue)r   r$   r&   rk   r_   arytypr:  r;  offseted_datar  r  r)  s               r5   r!   z_ArrayArgLoader.load  s    4::DIIcJ##F+w(++G,0,3KK8;-=>
 00'Bw))'*?*?

*KLu$+OOM49JJOO%E%*'.(/(<(<UZZ=E)G'+ 	 	-   rF   c                     t        j                  || j                        }t        j                  || j                        }||fS rB   )r   
pack_arrayr  r  )r   r$   r&   r  r  s        r5   r`  z"_ArrayArgLoader._shape_and_strides  s8    ""7DJJ7$$Wdll;g~rF   N)r   r   r   rY  r   r!   r`  r   rF   r5   rL  rL    s    !0rF   rL  c                       e Zd ZdZd Zy)rK  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                     |j                  t        j                  d      }|j                  t        j                  d      }t        j                  ||g      }t        j                  ||g      }||fS )Nr   r   )r   r   ro   r   rg  )r   r$   r&   oner   r  r  s          r5   r`  z*_ArrayAsScalarArgLoader._shape_and_strides  s`    ""5::q1##EJJ2""7SE2$$Wtf5g~rF   N)r   r   r   rY  r`  r   rF   r5   rK  rK    s    
rF   rK  )#collectionsr   numpyr&  llvmlite.irr   r   llvmliter   
numba.corer   r   numba.core.compiler_lockr	   numba.core.cachingr
   r   r   r6   r?   rI   r[   rb   r   objectr   r   r   r  r  r  r   rN  rL  rK  r   rF   r5   <module>rs     s    "  +  % 9 < ?,FG8@+D@+lI^&H &HR %U+xV xv$> $"]2@>: >:B"v "((f (Vo rF   