Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre committed Jun 18, 2024
1 parent 5d7e49b commit 2fee5c0
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions onnxscript/tools/memory_peak.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright (c) Microsoft Corporation.
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
# pylint: disable=import-outside-toplevel
from __future__ import annotations

import dataclasses
import multiprocessing
import os

Expand All @@ -12,11 +13,8 @@ def get_memory_rss(pid: int) -> int:
"""
Returns the physical memory used by a process.
Args:
pid: process id, current one is `os.getpid()`
Returns:
physical memory
:param pid: process id, current one is `os.getpid()`
:return: physical memory
It relies on the module :epkg:`psutil`.
"""
Expand All @@ -27,13 +25,13 @@ def get_memory_rss(pid: int) -> int:
return mem

Check warning on line 25 in onnxscript/tools/memory_peak.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/tools/memory_peak.py#L23-L25

Added lines #L23 - L25 were not covered by tests


@dataclasses.dataclass
class Monitor:
max_peak: float = 0
average: float = 0
n_measures: int = 0
begin: float = 0
end: float = 0
def __init__(self):
self.max_peak: float = 0
self.average: float = 0
self.n_measures: int = 0
self.begin: float = 0
self.end: float = 0

Check warning on line 34 in onnxscript/tools/memory_peak.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/tools/memory_peak.py#L30-L34

Added lines #L30 - L34 were not covered by tests

def to_dict(self, unit: int = 1) -> dict[str, float]:
funit = float(unit)
Expand Down

0 comments on commit 2fee5c0

Please sign in to comment.