utils.time_helper¶
time_helper¶
Please Reference ding/ding/utils/time_helper.py for usage.
build_time_helper¶
- Overview:
Build the timehelper
- Arguments:
- cfg (
dict
): The config file, which is a multilevel dict, have large domain like evaluate, common, model, train etc, and each large domain has it’s smaller domain.
- cfg (
wrapper_type (
str
): The type of wrapper returned, support['time', 'cuda']
- Returns:
- time_wrapper (
TimeWrapper
): Return the corresponding timewrapper, Reference:
ding.utils.timehelper.TimeWrapperTime
andding.utils.timehelper.get_cuda_time_wrapper
.
- time_wrapper (
TimeWrapper¶
TimeWrapperTime¶
- class ding.utils.time_helper.TimeWrapperTime[source]¶
- Overview:
A class method that inherit from
TimeWrapper
class- Interface:
start_time
,end_time
get_cuda_time_wrapper¶
- Overview:
Return the
TimeWrapperCuda
class, this wrapper aims to ensure compatibility in no cuda device- Returns:
TimeWrapperCuda(
class
): SeeTimeWrapperCuda
class
Note
Must use torch.cuda.synchronize()
, reference: <https://blog.csdn.net/u013548568/article/details/81368019>
EasyTimer¶
WatchDog¶
- class ding.utils.time_helper.WatchDog(timeout: int = 1)[source]¶
- Overview:
Simple watchdog timer to detect timeouts
- Arguments:
timeout (
int
): Timeout value of thewatchdog [seconds]
.
Note
If it is not reset before exceeding this value,
TimeourError
raised.- Interface:
start
,stop
- Examples:
>>> watchdog = WatchDog(x) # x is a timeout value >>> ... >>> watchdog.start() >>> ... # Some function