
    9iv                        S SK Jr  S SKJr  SSKJr  \R                  " \R                  S9 " S S\5      5       r\R                  " \R                  S9 " S S	\5      5       r\R                  " \R                  S9 " S
 S\5      5       r	g)    )LR_Schedulers)LR_SCHEDULER   )
BaseWarmup)module_namec                   :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )ConstantWarmup   a2  Linear warmup scheduler.

Args:
    base_scheduler (torch.optim._LRScheduler): an instance of torch.optim._LRScheduler type
    warmup_ratio (float): Lr used at warmup stage equals to warmup_ratio * initial_lr
    warmup_iters (int | list): Warmup iterations
    last_epoch (int): The index of last epoch.
c                 6   > X0l         [        [        U ]  XUS9  g N)warmup_iters
last_epoch)warmup_ratiosuperr	   __init__selfbase_schedulerr   r   r   	__class__s        m/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/trainers/lrscheduler/warmup/warmup.pyr   ConstantWarmup.__init__   s%    
 )nd,* 	- 	N    c                 :    XR                   :  a  gU R                  $ )Ng      ?r   r   )r   cur_iters     r   get_warmup_scaleConstantWarmup.get_warmup_scale   s    (((   r   r   g?	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classcell__r   s   @r   r	   r	      s      "	N! !r   r	   c                   :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )LinearWarmup!   a=  Linear warmup scheduler.

Args:
    base_scheduler (torch.optim._LRScheduler): an instance of torch.optim._LRScheduler type
    warmup_iters (int | list): Warmup iterations
    warmup_ratio (float): Lr used at the beginning of warmup equals to warmup_ratio * initial_lr
    last_epoch (int): The index of last epoch.
c                 6   > X0l         [        [        U ]  XUS9  g r   )r   r   r+   r   r   s        r   r   LinearWarmup.__init__,   s%    
 )lD** 	+ 	Nr   c                 N    SXR                   -  -
  SU R                  -
  -  nSU-
  $ Nr   r   r   r   ks      r   r   LinearWarmup.get_warmup_scale5   s.    ----!d6G6G2GH1ur   r   r   r!   r)   s   @r   r+   r+   !   s      "	N r   r+   c                   :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )ExponentialWarmup:   aB  Exponential warmup scheduler.

Args:
    base_scheduler (torch.optim._LRScheduler): an instance of torch.optim._LRScheduler type
    warmup_iters (int | list): Warmup iterations
    warmup_ratio (float): Lr used at the beginning of warmup equals to warmup_ratio * initial_lr
    last_epoch (int): The index of last epoch.
c                 6   > X0l         [        [        U ]  XUS9  g r   )r   r   r5   r   r   s        r   r   ExponentialWarmup.__init__E   s&    
 )/* 	0 	Nr   c                 B    U R                   SXR                  -  -
  -  nU$ r0   )r   r   r1   s      r   r   "ExponentialWarmup.get_warmup_scaleN   s%    H/@/@$@ @Ar   r   r   r!   r)   s   @r   r5   r5   :   s      "	N r   r5   N)
modelscope.metainfor   'modelscope.trainers.lrscheduler.builderr   baser   register_moduler	   r+   r5    r   r   <module>r@      s    - @  -*F*FG!Z ! H!2 -*D*DE:  F0 -*I*IJ
  Kr   