_monitor.pyi 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Defined in torch/csrc/monitor/python_init.cpp
  2. import datetime
  3. from enum import Enum
  4. from typing import Callable, Dict, List, Union
  5. class Aggregation(Enum):
  6. VALUE = ...
  7. MEAN = ...
  8. COUNT = ...
  9. SUM = ...
  10. MAX = ...
  11. MIN = ...
  12. class Stat:
  13. name: str
  14. count: int
  15. def __init__(
  16. self,
  17. name: str,
  18. aggregations: List[Aggregation],
  19. window_size: int,
  20. max_samples: int = -1,
  21. ) -> None: ...
  22. def add(self, v: float) -> None: ...
  23. def get(self) -> Dict[Aggregation, float]: ...
  24. class Event:
  25. name: str
  26. timestamp: datetime.datetime
  27. data: Dict[str, Union[int, float, bool, str]]
  28. def __init__(
  29. self,
  30. name: str,
  31. timestamp: datetime.datetime,
  32. data: Dict[str, Union[int, float, bool, str]],
  33. ) -> None: ...
  34. def log_event(e: Event) -> None: ...
  35. class EventHandlerHandle: ...
  36. def register_event_handler(handler: Callable[[Event], None]) -> EventHandlerHandle: ...
  37. def unregister_event_handler(handle: EventHandlerHandle) -> None: ...