
    `i                     T    d dl Z d dlmZ d dlmZ d dlmZ d Z G d de          ZdS )    N)_core)
_interface)_cuda_typesc                     t          | t                    rdS t          | t                    rdS t          | t                    rdS | j        j        S )NldD)
isinstanceintfloatcomplexdtypechar)args    n/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupy/_functional/vectorize.py_get_input_typer      sQ    #s s#u s#w s9>    c                   :    e Zd ZdZ	 	 ddZed             Zd ZdS )	vectorizezKGeneralized function class.

    .. seealso:: :class:`numpy.vectorize`
    NFc                    || _         |p|j        | _        || _        || _        || _        i | _        d| _        |$d                    d |D                       | _        |t          d          |t          d          dS )ab  
        Args:
            pyfunc (callable): The target python function.
            otypes (str or list of dtypes, optional): The output data type.
            doc (str or None): The docstring for the function.
            excluded: Currently not supported.
            cache: Currently Ignored.
            signature: Currently not supported.
        N c                 @    g | ]}t          j        |          j        S  )numpyr   r   .0ts     r   
<listcomp>z&vectorize.__init__.<locals>.<listcomp>.   s#    "G"G"G15;q>>#6"G"G"Gr   z<cupy.vectorize does not support `excluded` option currently.z=cupy.vectorize does not support `signature` option currently.)	pyfunc__doc__excludedcache	signature_kernel_cacheotypesjoinNotImplementedError)selfr   r%   docr!   r"   r#   s          r   __init__zvectorize.__init__   s     ,fn 
"''"G"G"G"G"GHHDK%NP P P  %%& & & ! r   c                    t          | t          j                  r| j        g}d| d}nt          | t          j                  rug }d| d}t          | j                  D ]W\  }}t          |t          j                  st          d|            |                    |j                   |d| d| dz  }Xnt          d|            d	 t          |          D             }d
	                    |          |fS )Nzout0 = ;zauto out = z;
zInvalid return type: outz = STD::get<z>(out);
c                 "    g | ]\  }}| d | S )z outr   )r   ir   s      r   r   z'vectorize._get_body.<locals>.<listcomp>J   s*    JJJHAu''A''JJJr   , )
r
   r   Scalarr   Tuple	enumeratetypes	TypeErrorappendr&   )return_typecalldtypescoder/   r   
out_paramss          r   	_get_bodyzvectorize._get_body9   s/   k;#566 	C!'(F$T$$$DD[%677 
	CF****D!+"344 : :1!![%788 K#$IK$I$IJJJag&&&9a99Q9999: AKAABBBJJ	&8I8IJJJ
yy$$d**r   c                    d                     d |D                       }| j                            |d           }|d |D             }d }| j        t          t          j        | j        dd          }|                    ||          }d                     d t          |          D                       }d                     d	 t          t          |                    D                       }	|j         d
|	 d}
|                     |j        |
          \  }}t          j        |||d|j        d          }|| j        |<    || S )Nr   c                 ,    g | ]}t          |          S r   )r   )r   xs     r   r   z&vectorize.__call__.<locals>.<listcomp>N   s     ;;;/!,,;;;r   c                 6    g | ]}t          j        |          S r   )r   r1   r   s     r   r   z&vectorize.__call__.<locals>.<listcomp>R   s#    >>>!*1-->>>r   r   T)devicer0   c              3   4   K   | ]\  }}|j          d | V  dS )z inN)r   )r   r/   r   s      r   	<genexpr>z%vectorize.__call__.<locals>.<genexpr>Z   sO       "D "D'+q!17""q"""D "D "D "D "D "Dr   c                     g | ]}d | S )inr   )r   r/   s     r   r   z&vectorize.__call__.<locals>.<listcomp>\   s     H H Haa H H Hr   ()cupy_vectorize)z-DCUPY_JIT_MODEz--std=c++17)preambleoptions)r&   r$   getr%   r'   r   _CudaFunctionr   _emit_code_from_typesr3   rangelen	func_namer<   r7   r   ElementwiseKernelr:   )r(   argsitypeskernin_typesret_typefuncresult	in_paramsin_argsr8   r;   bodys                r   __call__zvectorize.__call__M   sy   ;;d;;;<<!%%fd33<>>v>>>HH{&))+DKNNND//(CCF		 "D "D/8/B/B"D "D "D D DIii H H5X3G3G H H HIIG&33333D#~~f.@$GGJ *:t-=:  D
 *.Dv&tT{r   )NNNFN)__name__
__module____qualname__r    r*   staticmethodr<   r\   r   r   r   r   r      se          ;?#'& & & &B + + \+&    r   r   )	r   cupyr   	cupyx.jitr   r   r   objectr   r   r   r   <module>rd      s                       ! ! ! ! ! !  W W W W W W W W W Wr   