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_timer can 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_env to 1 to enable logging! default is TIMER=1.

__init__(name=None, flag_env='TIMER', logger_func=<built-in function print>)[source]

Super-resolution

Grid-put