
    `i                         d dl Z d dl mZ  ej        dddd           ej        dddd          d	ZddZ ej        dddd           ej        dddd          d	ZddZdS )    N)_corezraw T a, raw int32 a_sizezuint8 packedzfor (int j = 0; j < 8; ++j) {
                    int k = i * 8 + j;
                    int bit = k < a_size && a[k] != 0;
                    packed |= bit << (7 - j);
                }cupy_packbits_bigzfor (int j = 0; j < 8; ++j) {
                    int k = i * 8 + j;
                    int bit = k < a_size && a[k] != 0;
                    packed |= bit << j;
                }cupy_packbits_littlebiglittler   c                 @   | j         j        dvrt          d          |t          d          |dvrt	          d          |                                 } | j        dz   dz  }t          j        |ft          j	        	          }t          |         | | j        |          S )
a  Packs the elements of a binary-valued array into bits in a uint8 array.

    This function currently does not support ``axis`` option.

    Args:
        a (cupy.ndarray): Input array.
        axis (int, optional): Not supported yet.
        bitorder (str, optional): bit order to use when packing the array,
            allowed values are `'little'` and `'big'`. Defaults to `'big'`.

    Returns:
        cupy.ndarray: The packed array.

    .. note::
        When the input array is empty, this function returns a copy of it,
        i.e., the type of the output array is not necessarily always uint8.
        This exactly follows the NumPy's behaviour (as of version 1.11),
        alghough this is inconsistent to the documentation.

    .. seealso:: :func:`numpy.packbits`
    biuz7Expected an input array of integer or boolean data typeN axis option is not supported yetr   )bitorder must be either 'big' or 'little'      dtype)r   kind	TypeErrorNotImplementedError
ValueErrorravelsizecupyzerosuint8_packbits_kernel)aaxisbitorderpacked_sizepackeds        h/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupy/_binary/packing.pypackbitsr!      s    , 	w|5  EG G 	G !"DEEE(((DEEE			A6A:!#KZdj999FH%a888    zraw uint8 az
T unpackedz)unpacked = (a[i / 8] >> (7 - i % 8)) & 1;cupy_unpackbits_bigz%unpacked = (a[i / 8] >> (i % 8)) & 1;cupy_unpackbits_littlec                    | j         t          j        k    rt          d          |t	          d          |dvrt          d          t          j        | j        dz  t          j                  }t          |         | |          S )a  Unpacks elements of a uint8 array into a binary-valued output array.

    This function currently does not support ``axis`` option.

    Args:
        a (cupy.ndarray): Input array.
        bitorder (str, optional): bit order to use when unpacking the array,
            allowed values are `'little'` and `'big'`. Defaults to `'big'`.

    Returns:
        cupy.ndarray: The unpacked array.

    .. seealso:: :func:`numpy.unpackbits`
    z2Expected an input array of unsigned byte data typeNr   r   r   r   r   )	r   r   r   r   r   r   ndarrayr   _unpackbits_kernel)r   r   r   unpackeds       r    
unpackbitsr)   O   s     	w$*LMMM!"DEEE(((DEEE|QVaZ
;;;Hh'8444r"   )Nr   )r   r   ElementwiseKernelr   r!   r'   r)    r"   r    <module>r,      s           #5"#^	
 	  &e%#^	
 	   ,#9 #9 #9 #9N #5"|3 
 &e%|/    5 5 5 5 5 5r"   