
    
9j                    r    S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S r	\
S4S jrSS	 jr\
S4S
 jrSS jrg)    )annotationsN)cuda)_new_like_order_and_strides)internalc                x    Uc  U b  U R                   nU$ [        U[        5      (       a  U4nU$ [        U5      nU$ )N)shape
isinstanceinttuple)ar   s     M/home/wildlama/miniconda3/lib/python3.13/site-packages/cupyx/_pinned_array.py_update_shaper   
   sH    }
 L	 
E3		 L eL    Cc                    [        SU 5      n [        R                  " U 5      [        R                  " U5      R
                  -  n[        R                  " U5      n[        R                  " XXBS9nU$ )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      sW    & $&E]]5!EKK$6$?$??F

"
"6
*C
--3
DCJr   c                8   Ub  [        S5      eUc  U R                  n[        X5      n[        XX$SS9u  p%n[        R
                  " U5      [        R                  " U5      R                  -  n[        R                  " U5      n[        R                  " XAUXRS9n	U	$ )aU  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`

z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}!#E3	%52EA]]5!EKK$6$?$??F

"
"6
*C
--3 '6CJr   c                J    [        XU5      n[        R                  " USSS9  U$ )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*   Z   s%    & uU
+C	LLa*Jr   c                L    [        XX#U5      n[        R                  " USSS9  U$ )a  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,   r   s'    6 AeE
:C	LLa*Jr   )NKNN)
__future__r   r   cupyr   cupy._creation.basicr   
cupy._corer   r   floatr   r$   r*   r,    r   r   <module>r4      s<    "   <  $3 4)X $3 0r   