mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[pytorch][counters] Pybind for WaitCounter (#132357)
Summary: Basic pybind integration for WaitCounter providing a guard API. Also fixes broken copy/move constructor in WaitGuard (it wasn't really used with the macro-based C++ API). Test Plan: unit test Differential Revision: D60557660 Pull Request resolved: https://github.com/pytorch/pytorch/pull/132357 Approved by: https://github.com/jamesperng, https://github.com/asiab4
This commit is contained in:
committed by
PyTorch MergeBot
parent
d224857b3a
commit
fca2dba7ca
@ -1,22 +1,21 @@
|
||||
# Owner(s): ["oncall: r2p"]
|
||||
|
||||
from torch.testing._internal.common_utils import (
|
||||
TestCase, run_tests, skipIfTorchDynamo,
|
||||
)
|
||||
|
||||
from datetime import timedelta, datetime
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from torch.monitor import (
|
||||
Aggregation,
|
||||
Event,
|
||||
log_event,
|
||||
register_event_handler,
|
||||
unregister_event_handler,
|
||||
Stat,
|
||||
TensorboardEventHandler,
|
||||
unregister_event_handler,
|
||||
_WaitCounter,
|
||||
)
|
||||
from torch.testing._internal.common_utils import run_tests, skipIfTorchDynamo, TestCase
|
||||
|
||||
class TestMonitor(TestCase):
|
||||
def test_interval_stat(self) -> None:
|
||||
@ -98,6 +97,13 @@ class TestMonitor(TestCase):
|
||||
log_event(e)
|
||||
self.assertEqual(len(events), 2)
|
||||
|
||||
def test_wait_counter(self) -> None:
|
||||
wait_counter = _WaitCounter(
|
||||
"test_wait_counter",
|
||||
)
|
||||
with wait_counter.guard() as wcg:
|
||||
pass
|
||||
|
||||
|
||||
@skipIfTorchDynamo("Really weird error")
|
||||
class TestMonitorTensorboard(TestCase):
|
||||
|
Reference in New Issue
Block a user