
    `i                         d dl Z d dlmZ d dlmZ ddddZdddd	Zdddd
ZddZddZ	d Z
d Zd Zd Zd Zd Zd ZdS )    N)_core)fusionTKFblockingc          	      6    t          j        | ||||||          S )a  Creates an array on the current device.

    This function currently does not support the ``subok`` option.

    Args:
        obj: :class:`cupy.ndarray` object or any other object that can be
            passed to :func:`numpy.array`.
        dtype: Data type specifier.
        copy (bool): If ``False``, this function returns ``obj`` if possible.
            Otherwise this function always returns a new array.
        order ({'C', 'F', 'A', 'K'}): Row-major (C-style) or column-major
            (Fortran-style) order.
            When ``order`` is ``'A'``, it uses ``'F'`` if ``a`` is column-major
            and uses ``'C'`` otherwise.
            And when ``order`` is ``'K'``, it keeps strides as closely as
            possible.
            If ``obj`` is :class:`numpy.ndarray`, the function returns ``'C'``
            or ``'F'`` order array.
        subok (bool): If ``True``, then sub-classes will be passed-through,
            otherwise the returned array will be forced to be a base-class
            array (default).
        ndmin (int): Minimum number of dimensions. Ones are inserted to the
            head of the shape if needed.
        blocking (bool): Default is ``False``, meaning if a H2D copy is needed
            it would run asynchronously on the current stream, and users are
            responsible for ensuring the stream order. For example, writing to
            the source ``obj`` without proper ordering while copying would
            result in a race condition. If set to ``True``, the copy is
            synchronous (with respect to the host).

    Returns:
        cupy.ndarray: An array on the current device.

    .. note::
       This method currently does not support ``subok`` argument.

    .. note::
       If ``obj`` is an `numpy.ndarray` instance that contains big-endian data,
       this function automatically swaps its byte order to little-endian,
       which is the NVIDIA and AMD GPU architecture's native use.

    .. seealso:: :func:`numpy.array`

    r   array)objdtypecopyordersubokndminr   s          l/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupy/_creation/from_data.pyr
   r
      s!    \ ;sE4uhGGG    c                4    t          j        | |d||          S )ag  Converts an object to array.

    This is equivalent to ``array(a, dtype, copy=False, order=order)``.

    Args:
        a: The source object.
        dtype: Data type specifier. It is inferred from the input by default.
        order ({'C', 'F', 'A', 'K'}):
            Whether to use row-major (C-style) or column-major (Fortran-style)
            memory representation. Defaults to ``'K'``. ``order`` is ignored
            for objects that are not :class:`cupy.ndarray`, but have the
            ``__cuda_array_interface__`` attribute.
        blocking (bool): Default is ``False``, meaning if a H2D copy is needed
            it would run asynchronously on the current stream, and users are
            responsible for ensuring the stream order. For example, writing to
            the source ``a`` without proper ordering while copying would
            result in a race condition. If set to ``True``, the copy is
            synchronous (with respect to the host).

    Returns:
        cupy.ndarray: An array on the current device. If ``a`` is already on
        the device, no copy is performed.

    .. note::
       If ``a`` is an `numpy.ndarray` instance that contains big-endian data,
       this function automatically swaps its byte order to little-endian,
       which is the NVIDIA and AMD GPU architecture's native use.

    .. seealso:: :func:`numpy.asarray`

    Fr   r	   ar   r   r   s       r   asarrayr   8   s     @ ;q%AAAAr   c                4    t          j        | |d||          S )ar  Converts an object to array.

    This is currently equivalent to :func:`cupy.asarray`, since there is no
    subclass of :class:`cupy.ndarray` in CuPy. Note that the original
    :func:`numpy.asanyarray` returns the input array as is if it is an instance
    of a subtype of :class:`numpy.ndarray`.

    .. seealso:: :func:`cupy.asarray`, :func:`numpy.asanyarray`

    Fr   r	   r   s       r   
asanyarrayr   [   s     ;q%AAAAr   c                 ,    t          j        | |          S )a)  Returns a C-contiguous array.

    Args:
        a (cupy.ndarray): Source array.
        dtype: Data type specifier.

    Returns:
        cupy.ndarray: If no copy is required, it returns ``a``. Otherwise, it
        returns a copy of ``a``.

    .. seealso:: :func:`numpy.ascontiguousarray`

    )r   ascontiguousarray)r   r   s     r   r   r   i   s     "1e,,,r   c                     t          j                    r4|dk    rt          d          t          j        t          j        |           S |                     |          S )a  Creates a copy of a given array on the current device.

    This function allocates the new array on the current device. If the given
    array is allocated on the different device, then this function tries to
    copy the contents over the devices.

    Args:
        a (cupy.ndarray): The source array.
        order ({'C', 'F', 'A', 'K'}): Row-major (C-style) or column-major
            (Fortran-style) order.
            When ``order`` is ``'A'``, it uses ``'F'`` if ``a`` is column-major
            and uses ``'C'`` otherwise.
            And when ``order`` is ``'K'``, it keeps strides as closely as
            possible.

    Returns:
        cupy.ndarray: The copy of ``a`` on the current device.

    .. seealso:: :func:`numpy.copy`, :meth:`cupy.ndarray.copy`

    r   z1cupy.copy does not support `order` in fusion yet.)r   )r   
_is_fusingNotImplementedError_call_ufuncr   elementwise_copyr   )r   r   s     r   r   r   |   sb    ,  =C<<%CE E E!%"8!<<<
 666r   c                  >    t          t          j        | i |          S )zInterpret a buffer as a 1-dimensional array.

    .. note::
        Uses NumPy's ``frombuffer`` and coerces the result to a CuPy array.

    .. seealso:: :func:`numpy.frombuffer`

    )r   numpy
frombufferargskwargss     r   r"   r"      s"     5#T4V44555r   c                  >    t          t          j        | i |          S )ay  Reads an array from a file.

    .. note::
        Uses NumPy's ``fromfile`` and coerces the result to a CuPy array.

    .. note::
       If you let NumPy's ``fromfile`` read the file in big-endian, CuPy
       automatically swaps its byte order to little-endian, which is the NVIDIA
       and AMD GPU architecture's native use.

    .. seealso:: :func:`numpy.fromfile`

    )r   r!   fromfiler#   s     r   r'   r'      s!     5>42622333r   c                  >    t          t          j        | i |          S )zConstruct an array by executing a function over each coordinate.

    .. note::
        Uses NumPy's ``fromfunction`` and coerces the result to a CuPy array.

    .. seealso:: :func:`numpy.fromfunction`
    )r   r!   fromfunctionr#   s     r   r)   r)      s"     5%t6v66777r   c                  >    t          t          j        | i |          S )zCreate a new 1-dimensional array from an iterable object.

    .. note::
        Uses NumPy's ``fromiter`` and coerces the result to a CuPy array.

    .. seealso:: :func:`numpy.fromiter`
    )r   r!   fromiterr#   s     r   r+   r+      s!     5>42622333r   c                  >    t          t          j        | i |          S )zA new 1-D array initialized from text data in a string.

    .. note::
        Uses NumPy's ``fromstring`` and coerces the result to a CuPy array.

    .. seealso:: :func:`numpy.fromstring`
    )r   r!   
fromstringr#   s     r   r-   r-      "     5#T4V44555r   c                  >    t          t          j        | i |          S )zLoad data from a text file.

    .. note::
        Uses NumPy's ``loadtxt`` and coerces the result to a CuPy array.

    .. seealso:: :func:`numpy.loadtxt`
    )r   r!   loadtxtr#   s     r   r0   r0      s!     5=$1&11222r   c                  >    t          t          j        | i |          S )zLoad data from text file, with missing values handled as specified.

    .. note::
        Uses NumPy's ``genfromtxt`` and coerces the result to a CuPy array.

    .. seealso:: :func:`numpy.genfromtxt`
    )r   r!   
genfromtxtr#   s     r   r2   r2      r.   r   )NTr   Fr   )NN)N)r   )r!   cupyr   
cupy._corer   r
   r   r   r   r   r"   r'   r)   r+   r-   r0   r2    r   r   <module>r6      sC               .H.H .H .H .H .Hb B5  B  B  B  B  BFBe B B B B B- - - -&   D	6 	6 	64 4 4"8 8 84 4 46 6 63 3 36 6 6 6 6r   