[misc] update pre-commit and run all files (#4752)

* [misc] update pre-commit

* [misc] run pre-commit

* [misc] remove useless configuration files

* [misc] ignore cuda for clang-format
This commit is contained in:
Hongxin Liu
2023-09-19 14:20:26 +08:00
committed by GitHub
parent 3c6b831c26
commit 079bf3cb26
1268 changed files with 50037 additions and 38444 deletions

View File

@@ -2,12 +2,12 @@
# -*- encoding: utf-8 -*-
import time
from typing import Tuple
from .cuda import synchronize
class Timer:
"""A timer object which helps to log the execution times, and provides different tools to assess the times.
"""
"""A timer object which helps to log the execution times, and provides different tools to assess the times."""
def __init__(self):
self._started = False
@@ -25,16 +25,14 @@ class Timer:
return time.time()
def start(self):
"""Firstly synchronize cuda, reset the clock and then start the timer.
"""
"""Firstly synchronize cuda, reset the clock and then start the timer."""
self._elapsed = 0
synchronize()
self._start_time = time.time()
self._started = True
def lap(self):
"""lap time and return elapsed time
"""
"""lap time and return elapsed time"""
return self.current_time - self._start_time
def stop(self, keep_in_history: bool = False):
@@ -80,12 +78,11 @@ class Timer:
Note:
Use it only when timer is not in progress
"""
assert not self._started, 'Timer is still in progress'
assert not self._started, "Timer is still in progress"
return self._elapsed
def reset(self):
"""Clear up the timer and its history
"""
"""Clear up the timer and its history"""
self._history = []
self._started = False
self._elapsed = 0