U
    ‰dï  ã                   @   sD   d dl mZ d dlmZmZ G dd„ deejƒZG dd„ deƒZdS )é    )Úcontext)ÚModifierContextÚUseModifierBasec                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚNormalizerContextzK
    provide context to allow param_info to have different normalizers
    c                 C   s
   |   |¡S ©N)Z_has_modifier©ÚselfÚname© r
   úD/tmp/pip-unpacked-wheel-ua33x9lu/caffe2/python/normalizer_context.pyÚhas_normalizer   s    z NormalizerContext.has_normalizerc                 C   s"   |   |¡std |¡ƒ‚|  |¡S )Nz{} normalizer is not provided!)r   ÚAssertionErrorÚformatZ_get_modifierr   r
   r
   r   Úget_normalizer   s    ÿz NormalizerContext.get_normalizerN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r
   r
   r   r      s   r   c                   @   s   e Zd ZdZdd„ ZdS )ÚUseNormalizera  
    context class to allow setting the current context.
    Example usage with layer:
        normalizers = {'norm1': norm1, 'norm2': norm2}
        with UseNormalizer(normalizers):
            norm = NormalizerContext.current().get_normalizer('norm1')
            layer(norm=norm)
    c                 C   s   t S r   )r   )r   r
   r
   r   Ú_context_class$   s    zUseNormalizer._context_classN)r   r   r   r   r   r
   r
   r
   r   r      s   r   N)Zcaffe2.pythonr   Zcaffe2.python.modifier_contextr   r   ZDefaultManagedr   r   r
   r
   r
   r   Ú<module>   s   