o
    "Õj™  ã                   @   s>   d dl Z d dlZddlmZ ddgZdd„ ZG dd	„ d	ƒZdS )
é    Né   )ÚStrategyZshardingZ	recomputec                 C   s   t | |ƒ}|S ©N)Úgetattr)ÚstrategyZ	pass_nameÚconfig© r   úu/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/distributed/auto_parallel/static/tuner/config.pyÚ_get_pass_config   s   
r
   c                   @   s”   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zdd„ ZdS )ÚTuningConfiga  
    A uniform config wrap:
    distributed strategy: the user defined configuration for optimization pass
    tuning config: configuration for the tuning process: mode (profile or cost model), log dir, extra tuning config for optimization like search range for specific
    c                 C   s\   t |tƒs	tdƒ‚tƒ | _t |¡| _d | _d | _	d | _
d | _d | _d | _d | _|  ¡  d S )Nz.'strategy' must be object of class `Strategy`.)Ú
isinstancer   Ú	TypeErrorÚsetÚ_tuning_passes_nameÚcopyÚdeepcopyÚ_dist_strategyÚ_modeÚ_profile_start_stepÚ_profile_end_stepÚ_project_dirÚ_max_num_trialÚ_early_stopÚ_debugÚ_initialize)Úselfr   r   r   r	   Ú__init__#   s   
zTuningConfig.__init__c                 C   ó   | j S r   )r   ©r   r   r   r	   Úmode3   ó   zTuningConfig.modec                 C   r   r   )r   r   r   r   r	   Úprofile_start_step7   r    zTuningConfig.profile_start_stepc                 C   r   r   )r   r   r   r   r	   Úprofile_end_step;   r    zTuningConfig.profile_end_stepc                 C   r   r   )r   r   r   r   r	   Úproject_dir?   r    zTuningConfig.project_dirc                 C   r   r   )r   r   r   r   r	   Útuning_passes_nameC   r    zTuningConfig.tuning_passes_namec                 C   r   r   )r   r   r   r   r	   Úmax_num_trialG   r    zTuningConfig.max_num_trialc                 C   r   r   )r   r   r   r   r	   Ú
early_stopK   r    zTuningConfig.early_stopc                 C   r   r   )r   r   r   r   r	   ÚdebugO   r    zTuningConfig.debugc                 C   r   r   )r   r   r   r   r	   Údist_strategyS   r    zTuningConfig.dist_strategyc                 C   sÎ   | j j}| dd¡| _| dd¡| _| dd¡| _| dd¡| _| d	d ¡| _| d
d¡| _| dd ¡}|s?t	j
 t	 ¡ d¡}|| _tD ] }t| j |ƒrdt| j |ƒjrd| j |¡ t| j |ƒ}|| j|< qDd S )Nr   ZPROFILEr!   é
   r"   é   r%   é2   r&   r'   Fr#   ZOptimizationTuning)r   ZtuningÚgetr   r   r   r   r   r   ÚosÚpathÚjoinÚgetcwdr   Ú_tuning_supported_passesr   r
   Zenable_tuningr   ÚaddÚ__dict__)r   Ztuning_strategyr#   ÚpZ
p_strategyr   r   r	   r   X   s*   
ÿþ
€÷zTuningConfig._initializec                 C   s   t | j|ƒS r   )r   r   )r   Úitemr   r   r	   Ú__getattr__y   s   zTuningConfig.__getattr__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r!   r"   r#   r$   r%   r&   r'   r(   r   r6   r   r   r   r	   r      s.    








!r   )r   r-   r   r   r1   r
   r   r   r   r   r	   Ú<module>   s   