_monitor.pyi 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Defined in torch/csrc/monitor/python_init.cpp
  2. from typing import List, Dict, Callable, Union
  3. from enum import Enum
  4. import datetime
  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, name: str, aggregations: List[Aggregation], window_size: int,
  17. max_samples: int = -1,
  18. ) -> None: ...
  19. def add(self, v: float) -> None: ...
  20. def get(self) -> Dict[Aggregation, float]: ...
  21. class Event:
  22. name: str
  23. timestamp: datetime.datetime
  24. data: Dict[str, Union[int, float, bool, str]]
  25. def __init__(
  26. self,
  27. name: str,
  28. timestamp: datetime.datetime,
  29. data: Dict[str, Union[int, float, bool, str]],
  30. ) -> None: ...
  31. def log_event(e: Event) -> None: ...
  32. class EventHandlerHandle: ...
  33. def register_event_handler(handler: Callable[[Event], None]) -> EventHandlerHandle: ...
  34. def unregister_event_handler(handle: EventHandlerHandle) -> None: ...