Skip to content

Commit 62d5609

Browse files
authored
Fix timer for NPU&XPU (#8261)
* Fix timer for NPU&XPU * Fix NPU/XPU timer
1 parent 84615ea commit 62d5609

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

paddlenlp/trainer/plugins/timer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def __init__(self, name):
3232
def start(self):
3333
"""Start the timer."""
3434
assert not self.started_, f"{self.name} timer has already started"
35-
if "gpu" in paddle.device.get_device():
35+
if "cpu" not in paddle.device.get_device():
3636
paddle.device.synchronize()
3737
self.start_time = time.time()
3838
self.started_ = True
3939

4040
def stop(self):
4141
"""Stop the timers."""
4242
assert self.started_, f"{self.name} timer is not started."
43-
if "gpu" in paddle.device.get_device():
43+
if "cpu" not in paddle.device.get_device():
4444
paddle.device.synchronize()
4545
self.elapsed_ += time.time() - self.start_time
4646
self.started_ = False

0 commit comments

Comments
 (0)