
    `i                     `    d dl Z d dlmZ d dlmZ d dlmZ d ZedfdZ	dd	Z
edfd
ZddZdS )    N)cuda)_new_like_order_and_strides)internalc                 n    |
| | j         }n(t          |t                    r|f}nt          |          }|S )N)shape
isinstanceinttuple)ar   s     g/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/_pinned_array.py_update_shaper      s?    }	E3		 eL    Cc                     t          d|           } t          j        |           t          j        |          j        z  }t          j        |          }t          j        | |||          }|S )a"  Returns a new, uninitialized NumPy array with the given shape
    and dtype.

    This is a convenience function which is just :func:`numpy.empty`,
    except that the underlying memory is pinned/pagelocked.

    Args:
        shape (int or tuple of ints): Dimensionalities of the array.
        dtype: Data type specifier.
        order ({'C', 'F'}): Row-major (C-style) or column-major
            (Fortran-style) order.

    Returns:
        numpy.ndarray: A new array with elements not initialized.

    .. seealso:: :func:`numpy.empty`

    N)dtypebufferorder)	r   r   prodnumpyr   itemsizer   alloc_pinned_memoryndarray)r   r   r   nbytesmemouts         r   empty_pinnedr      sa    & $&&E]5!!EK$6$6$??F

"6
*
*C
-U3e
D
D
DCJr   Kc                 @   |t          d          || j        }t          | |          }t          | |||d          \  }}}t	          j        |          t          j        |          j        z  }t          j	        |          }t          j
        |||||          }	|	S )a  Returns a new, uninitialized NumPy array with the same shape and dtype
    as those of the given array.

    This is a convenience function which is just :func:`numpy.empty_like`,
    except that the underlying memory is pinned/pagelocked.

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

    Args:
        a (numpy.ndarray or cupy.ndarray): Base array.
        dtype: Data type specifier. The data type of ``a`` is used by default.
        order ({'C', 'F', 'A', or 'K'}): Overrides the memory layout of the
            result. ``'C'`` means C-order, ``'F'`` means F-order, ``'A'`` means
            ``'F'`` if ``a`` is Fortran contiguous, ``'C'`` otherwise.
            ``'K'`` means match the layout of ``a`` as closely as possible.
        subok: Not supported yet, must be None.
        shape (int or tuple of ints): Overrides the shape of the result. If
            ``order='K'`` and the number of dimensions is unchanged, will try
            to keep order, otherwise, ``order='C'`` is implied.

    Returns:
        numpy.ndarray: A new array with same shape and dtype of ``a`` with
        elements not initialized.

    .. seealso:: :func:`numpy.empty_like`

    Nzsubok is not supported yetF)
get_memptr)r   r   stridesr   )	TypeErrorr   r   r   r   r   r   r   r   r   r   )
r   r   r   subokr   r    _r   r   r   s
             r   empty_like_pinnedr$   ,   s    < 4555}!U##E3	5%52 2 2E7A]5!!EK$6$6$??F

"6
*
*C
-U3 'u6 6 6CJr   c                 V    t          | ||          }t          j        |dd           |S )a  Returns a new, zero-initialized NumPy array with the given shape
    and dtype.

    This is a convenience function which is just :func:`numpy.zeros`,
    except that the underlying memory is pinned/pagelocked.

    Args:
        shape (int or tuple of ints): Dimensionalities of the array.
        dtype: Data type specifier.
        order ({'C', 'F'}): Row-major (C-style) or column-major
            (Fortran-style) order.

    Returns:
        numpy.ndarray: An array filled with zeros.

    .. seealso:: :func:`numpy.zeros`

    r   unsafecasting)r   r   copyto)r   r   r   r   s       r   zeros_pinnedr*   X   s1    & ueU
+
+C	La****Jr   c                 Z    t          | ||||          }t          j        |dd           |S )aj  Returns a new, zero-initialized NumPy array with the same shape and dtype
    as those of the given array.

    This is a convenience function which is just :func:`numpy.zeros_like`,
    except that the underlying memory is pinned/pagelocked.

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

    Args:
        a (numpy.ndarray or cupy.ndarray): Base array.
        dtype: Data type specifier. The dtype of ``a`` is used by default.
        order ({'C', 'F', 'A', or 'K'}): Overrides the memory layout of the
            result. ``'C'`` means C-order, ``'F'`` means F-order, ``'A'`` means
            ``'F'`` if ``a`` is Fortran contiguous, ``'C'`` otherwise.
            ``'K'`` means match the layout of ``a`` as closely as possible.
        subok: Not supported yet, must be None.
        shape (int or tuple of ints): Overrides the shape of the result. If
            ``order='K'`` and the number of dimensions is unchanged, will try
            to keep order, otherwise, ``order='C'`` is implied.

    Returns:
        numpy.ndarray: An array filled with zeros.

    .. seealso:: :func:`numpy.zeros_like`

    r   r&   r'   )r$   r   r)   )r   r   r   r"   r   r   s         r   zeros_like_pinnedr,   p   s5    6 AueUE
:
:C	La****Jr   )Nr   NN)r   cupyr   cupy._creation.basicr   
cupy._corer   r   floatr   r$   r*   r,    r   r   <module>r2      s           < < < < < <         $3    4) ) ) )X $3    0     r   