make_scheduler

paddle.profiler. make_scheduler ( *, closed: int, ready: int, record: int, repeat: int = 0, skip_first: int = 0 ) Callable [source]

Return a scheduler function, which scheduler the ProfilerState according to the setting. The state transform confirms to:

(CLOSED)  (CLOSED)    (CLOSED)  (READY)    (RECORD,last RETURN)      (CLOSED)
START -> skip_first -> closed -> ready    ->    record       ->      END
                        |                        |
                        |                        | (if has_repeated < repeat)
                        - - - - - - - - - - - -
Note that repeat <= 0 means the cycle will continue until the profiler exits.
Parameters
  • closed (int) – The number of steps in state ProfilerState.CLOSED.

  • ready (int) – The number of steps in state ProfilerState.READY.

  • record (int) – The number of steps in state ProfilerState.RECORD, and the state in last step will be set as ProfilerState.RECORD_AND_RETURN.

  • repeat (int, optional) – The number of cycles to repeat above state transform. Default value is 0, which means it will repeat this cycle until profiler exits.

  • skip_first (int, optional) – The number of first steps to drop, not participate in the state transform, and at ProfilerState.CLOSED state. Default value is 0.

Returns

A scheduler function, conforms to above state transform setting. The function will takes one parameter step_num, and returns corresponding ProfilerState.

Examples

  1. profiling range [2, 5].

Assume batch 0: closed, batch 1: ready, batch [2, 5] record.

>>> import paddle.profiler as profiler
>>> profiler.make_scheduler(closed=1, ready=1, record=4, repeat=1)
  1. profiling range [3,6], [9,12], [15,18].

Assume batch 0: skiped, batch 1: closed, batch 2: ready, batch [3,6]: record, repeat.

>>> import paddle.profiler as profiler
>>> profiler.make_scheduler(closed=1, ready=1, record=4, skip_first=1)