Skip to content

Commit

Permalink
rename module
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre committed Jun 19, 2024
1 parent 6349892 commit 2f38350
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions onnxscript/tools/benchmark/export_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def main(args=None):

# Import is delayed so that help is being display faster (without having to import heavy packages).
import onnxscript.tools
import onnxscript.tools.memory_peak as mpk
import onnxscript.tools.memory_peak
import onnxscript.tools.transformers_models

print(
Expand Down Expand Up @@ -127,7 +127,7 @@ def main(args=None):
filename = f"em_{name}.onnx"

memory_session = (

Check warning on line 129 in onnxscript/tools/benchmark/export_model.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/tools/benchmark/export_model.py#L129

Added line #L129 was not covered by tests
mpk.start_spying_on(cuda=kwargs["device"] == "cuda")
onnxscript.tools.memory_peak.start_spying_on(cuda=kwargs["device"] == "cuda")
if kwargs["memory_peak"]
else None
)
Expand All @@ -148,7 +148,9 @@ def main(args=None):
if memory_session is not None:
memory_results = memory_session.stop()
print(f"[export_model] ends memory monitoring {memory_results}")
memory_stats = mpk.flatten(memory_results, prefix="memory_")
memory_stats = onnxscript.tools.memory_peak.flatten(

Check warning on line 151 in onnxscript/tools/benchmark/export_model.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/tools/benchmark/export_model.py#L149-L151

Added lines #L149 - L151 were not covered by tests
memory_results, prefix="memory_"
)
else:
memory_stats = {}

Check warning on line 155 in onnxscript/tools/benchmark/export_model.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/tools/benchmark/export_model.py#L155

Added line #L155 was not covered by tests

Expand Down
8 changes: 4 additions & 4 deletions onnxscript/tools/memory_peak_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import numpy as np
import torch

import onnxscript.tools.memory_peak as mpeak
import onnxscript.tools.memory_peak


class TestMemoryPeak(unittest.TestCase):
def test_memory(self):
mem = mpeak.get_memory_rss(os.getpid())
mem = onnxscript.tools.memory_peak.get_memory_rss(os.getpid())
self.assertIsInstance(mem, int)

def test_spy(self):
p = mpeak.start_spying_on()
p = onnxscript.tools.memory_peak.start_spying_on()
res = []
for i in range(10):
time.sleep(0.005)
Expand All @@ -31,7 +31,7 @@ def test_spy(self):

@unittest.skipIf(not torch.cuda.is_available(), reason="CUDA not here")
def test_spy_cuda(self):
p = mpeak.start_spying_on(cuda=True)
p = onnxscript.tools.memory_peak.start_spying_on(cuda=True)
res = []

Check warning on line 35 in onnxscript/tools/memory_peak_test.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/tools/memory_peak_test.py#L34-L35

Added lines #L34 - L35 were not covered by tests
for i in range(10):
time.sleep(0.005)
Expand Down

0 comments on commit 2f38350

Please sign in to comment.