
    zj                        U d dl mZ d dlmZmZ d dlmZ d dlmZ ddl	m
Z
mZmZmZ erd dlmZ eeeef         Zded	<   ddZ	 dddZ	 dddZddZdd dZdd dZdd!dZdd!dZdS )"    )annotations)TYPE_CHECKINGUnion)	TypeAlias)core   )EventStreamcreate_eventcreate_stream)CPUPlacer   _CPUPlaceLikereturnintc                     dS )a2  
    Return the number of GPUs available.

    Returns:
        int: the number of GPUs available.

    Note:
        This function returns 0 when compiled without CUDA support.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> paddle.device.device_count()

    r    r       a/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/paddle/device/cpu.pydevice_countr   (   s	    $ 1r   Ndevice_CPUPlaceLike | Nonecore.GeneratorStatec                L    t          j                                                    S )a%  
    Get the random state for the default generator.

    Returns:
        Tensor: The random state tensor.

    Examples:

        .. code-block:: python

            >>> # doctest: +REQUIRES(env:CUSTOM_DEVICE)
            >>> import paddle
            >>> paddle.device.get_rng_state()

    )r   default_cpu_generator	get_stater   s    r   get_rng_stater   =   s    $ %''11333r   	new_stateNonec                R    t          j                                        |            dS )ar  
    Set the random number generator state of the specified device.

    Args:
        new_state (core.GeneratorState): The desired RNG state to set.
            This should be a state object previously obtained from ``get_rng_state()``.
        device (DeviceLike, optional): The device to set the RNG state for.
            If not specified, uses the current default device (as returned by ``paddle.framework._current_expected_place_()``).
            Can be a device object, integer device ID, or device string.

    Returns:
        None

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> # Save RNG state
            >>> state = paddle.device.get_rng_state()
            >>> # Do some random operations
            >>> x = paddle.randn([2, 3])
            >>> # Restore RNG state
            >>> paddle.device.set_rng_state(state)
    N)r   r   	set_state)r   r   s     r   set_rng_stater"   R   s'    6 	  **955555r   seedc                p    t          |           } t          j                                        |            dS )a  Set the seed for generating random numbers for the current Device.

    .. warning::
        If you are working with a multi-Device model, this function is insufficient
        to get determinism.  To seed all Devices, use :func:`manual_seed_all`.

    Sets the seed for global default generator, which manages the random number generation.

    Args:
        seed(int): The random seed to set.

    Returns:
        None

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> paddle.device.manual_seed(102)
            >>> # paddle.cuda.manual_seed(102) is equivalent to paddle.device.manual_seed(102)
            >>> paddle.cuda.manual_seed(102)

    N)r   r   r   manual_seed)r#   s    r   r%   r%   p   s2    0 t99D  ,,T22222r   c                     t          d          )z
    The API max_memory_allocated is not supported in CPU PaddlePaddle.
    Please reinstall PaddlePaddle with GPU or XPU support to call this API.
    zThe API paddle.device.max_memory_allocated is not supported in CPU PaddlePaddle. Please reinstall PaddlePaddle with GPU or XPU support to call this API.
ValueErrorr   s    r   max_memory_allocatedr)          
 	R  r   c                     t          d          )z
    The API max_memory_reserved is not supported in CPU PaddlePaddle.
    Please reinstall PaddlePaddle with GPU or XPU support to call this API.
    zThe API paddle.device.max_memory_reserved is not supported in CPU PaddlePaddle. Please reinstall PaddlePaddle with GPU or XPU support to call this API.r'   r   s    r   max_memory_reservedr,      r*   r   c                     t          d          )z
    The API reset_max_memory_allocated is not supported in CPU PaddlePaddle.
    Please reinstall PaddlePaddle with GPU or XPU support to call this API.
    zThe API paddle.device.reset_max_memory_allocated is not supported in CPU PaddlePaddle. Please reinstall PaddlePaddle with GPU or XPU support to call this API.r'   r   s    r   reset_max_memory_allocatedr.      r*   r   c                     t          d          )z
    The API reset_max_memory_reserved is not supported in CPU PaddlePaddle.
    Please reinstall PaddlePaddle with GPU or XPU support to call this API.
    zThe API paddle.device.reset_max_memory_reserved is not supported in CPU PaddlePaddle. Please reinstall PaddlePaddle with GPU or XPU support to call this API.r'   r   s    r   reset_max_memory_reservedr0      r*   r   )r   r   )N)r   r   r   r   )r   r   r   r   r   r   )r#   r   r   r   )r   r   r   r   )r   r   r   r   )
__future__r   typingr   r   typing_extensionsr   paddle.baser   custom_streamsr	   r
   r   r   paddler   strr   r   __annotations__r   r   r"   r%   r)   r,   r.   r0   r   r   r   <module>r9      s   # " " " " " " ' ' ' ' ' ' ' ' ' ' ' ' ' '                   $	 M       , $(4 4 4 4 4, DH6 6 6 6 6<3 3 3 38                  r   