mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/72009
This simplifies the Stats interface by merging IntervalStat and FixedCountStat into a single Stat w/ a specific window size duration and an optional max samples per window. This allows for the original intention of having comparably sized windows (for statistical purposes) while also having a consistent output bandwidth.
Test Plan:
```
buck test //caffe2/test:monitor //caffe2/test/cpp/monitor:monitor
```
Reviewed By: kiukchung
Differential Revision: D33822956
fbshipit-source-id: a74782492421be613a1a8b14341b6fb2e8eeb8b4
(cherry picked from commit 293b94e0b4)
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
# Defined in torch/csrc/monitor/python_init.cpp
|
|
|
|
from typing import List, Dict, Callable, Union
|
|
from enum import Enum
|
|
import datetime
|
|
|
|
class Aggregation(Enum):
|
|
VALUE = ...
|
|
MEAN = ...
|
|
COUNT = ...
|
|
SUM = ...
|
|
MAX = ...
|
|
MIN = ...
|
|
|
|
class Stat:
|
|
name: str
|
|
count: int
|
|
def __init__(
|
|
self, name: str, aggregations: List[Aggregation], window_size: int,
|
|
max_samples: int = -1,
|
|
) -> None: ...
|
|
def add(self, v: float) -> None: ...
|
|
def get(self) -> Dict[Aggregation, float]: ...
|
|
|
|
class Event:
|
|
name: str
|
|
timestamp: datetime.datetime
|
|
data: Dict[str, Union[int, float, bool, str]]
|
|
def __init__(
|
|
self,
|
|
name: str,
|
|
timestamp: datetime.datetime,
|
|
data: Dict[str, Union[int, float, bool, str]],
|
|
) -> None: ...
|
|
|
|
def log_event(e: Event) -> None: ...
|
|
|
|
class EventHandlerHandle: ...
|
|
|
|
def register_event_handler(handler: Callable[[Event], None]) -> EventHandlerHandle: ...
|
|
def unregister_event_handler(handle: EventHandlerHandle) -> None: ...
|