o
    "j                     @   sb   d dl mZmZ d dlZd dlmZ eG dd deZeG dd deZG dd	 d	ej	Z	dS )
    )IntEnumuniqueN)corec                   @   s$   e Zd ZdZdZdZdZdZdZdS )
DeviceTyper                  N)	__name__
__module____qualname__UNKNOWNZCPUZGPUZXPUZDCUZNIC r   r   s/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/distributed/auto_parallel/static/cluster_v2.pyr      s    r   c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )LinkTyper   r   r   r      r	   r
         N)r   r   r   r   ZLOCZSYSZPHBZPIXZPIBZNVLZNVBZNETr   r   r   r   r       s    r   c                   @   s&   e Zd ZdZdddZedd ZdS )
DeviceMesha  
    The class `DeviceMesh` describes the topology of physical devices.

    Args:
        mesh (list|numpy.array): an N-dimensional array describes the topology
            of logical processes.
        dim_names (list, optional): the i-th element of this list gives the name of the
            i-th dimension.

    Returns:
        None

    Examples:
        .. code-block:: python

            >>> # doctest: +REQUIRES(env:DISTRIBUTED)
            >>> import paddle
            >>> import paddle.distributed as dist

            >>> paddle.enable_static()

            >>> mesh = dist.DeviceMesh([[2, 4, 5], [0, 1, 3]])
            >>> assert mesh.shape == [2, 3]
            >>> assert mesh.device_ids == [2, 4, 5, 0, 1, 3]

    Nc                 C   s  || _ t|tst|tjstdt|trt|}|| _t| jj| _	| j
  | _tdd | jD s<J dt| jdksGJ dt| j}t|t| jksYJ d|d urnt|t| j	ksjJ d|| _nd	d
 tt| j	D | _tj| | j | j	| j| j d S )Nz3The mesh must be an instance of list or np.ndarray.c                 s   s    | ]}t |tV  qd S N)
isinstanceint).0pr   r   r   	<genexpr>X   s    

z&DeviceMesh.__init__.<locals>.<genexpr>z#All elements of the mesh be integerr   z&All elements of the mesh must be >= 0.z(All elements of the mesh must be unique.z?The length of dims_names must be same as the shape of the mesh.c                 S   s   g | ]}d t | qS )d)str)r   ir   r   r   
<listcomp>i   s    z'DeviceMesh.__init__.<locals>.<listcomp>)_namer   listnpZndarray
ValueErrorarray_meshshape_shapeflattentolistZ_device_idsallminsetlenZ
_dim_namesranger   r   __init__)selfnamemeshZ	dim_namesZunique_device_idsr   r   r   r/   I   sF   



zDeviceMesh.__init__c                 C   s   | j S r   )r%   )r0   r   r   r   r2   p   s   zDeviceMesh.meshr   )r   r   r   __doc__r/   propertyr2   r   r   r   r   r   -   s
    
'r   )
enumr   r   numpyr"   Zpaddle.frameworkr   r   r   r   r   r   r   r   <module>   s   	