Misc API¶
Miscellaneous API.
Sync timer¶
- class kiui.timer.sync_timer(name=None, flag_env='TIMER', logger_func=<built-in function print>)[source]¶
Synchronized timer to count the inference time of nn.Module.forward or else.
sync_timercan be used as a context manager or a decorator.Example as context manager:
with timer('name'): run()
Example as decorator:
@timer('name') def run(): pass
- Parameters:
name (str, optional) – name of the timer. Defaults to None.
flag_env (str, optional) – environment variable to check if logging is enabled. Defaults to “TIMER”.
logger_func (Callable, optional) – function to log the result. Defaults to
print.
Note
Set environment variable
$flag_envto1to enable logging! default isTIMER=1.