o
    Me8  ã                   @   s    d Z dd„ Zdd„ Zdd„ ZdS )Zlookup_tablec                    s\   |   ¡ j‰ g }|  ¡ jD ]}|jtkr+|| d¡d kr+| ‡ fdd„| d¡D ƒ¡ q|S )a  
    Find input variable of distribute lookup table in program.
    We only support one distribute table now.
    Args:
    program(Program): given program, locate distributed lookup table
    table_name(str): given table name that is found beforehand
    Returns:
    inputs
    ÚWé    c                    ó   g | ]}ˆ | ‘qS © r   ©Ú.0Úname©Ú
local_varsr   úTD:\Projects\ConvertPro\env\Lib\site-packages\paddle/fluid/distribute_lookup_table.pyÚ
<listcomp>!   ó    z8find_distributed_lookup_table_inputs.<locals>.<listcomp>ZIds)Úcurrent_blockÚvarsÚglobal_blockÚopsÚtypeÚLOOKUP_TABLE_TYPEÚinputÚextend)ÚprogramÚ
table_nameZinputsÚopr   r   r
   Ú$find_distributed_lookup_table_inputs   ó   


€r   c                    s\   |   ¡ j‰ g }|  ¡ jD ]}|jtkr+|| d¡d kr+| ‡ fdd„| d¡D ƒ¡ q|S )a  
    Find output variable of distribute lookup table in program.
    We only support one distribute table now.
    Args:
    program(Program): given program, locate distributed lookup table
    table_name(str): given table name that is found beforehand
    Returns:
    outputs
    r   r   c                    r   r   r   r   r   r   r
   r   4   r   z9find_distributed_lookup_table_outputs.<locals>.<listcomp>ZOut)	r   r   r   r   r   r   r   r   Úoutput)r   r   Zoutputsr   r   r   r
   Ú%find_distributed_lookup_table_outputs%   r   r   c                 C   s€   d}|   ¡ jD ]6}|jtkr=| d¡du r.|du r | d¡d }|| d¡d kr-tdƒ‚q|dur=| d¡d |ks=J ‚q|S )zÓ
    Find distribute lookup table in program.
    We only support one distribute table now.
    Args:
    program(Program): given program, locate distributed lookup table
    Returns:
    table_name or None
    NZis_distributedTr   r   z;all distributed lookup_table_ops should have only one table)r   r   r   r   Úattrr   ÚRuntimeError)r   r   r   r   r   r
   Úfind_distributed_lookup_table8   s   	
ÿ€r   N)r   r   r   r   r   r   r   r
   Ú<module>   s   