MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / MemStat

Class MemStat

imperative/python/test/unit/core/test_stream.py:11–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class MemStat:
12 def __init__(self, *args):
13 for d in args:
14 mge.Tensor([], device=d)
15 gc.collect()
16 mge._full_sync()
17 self.baseline = {d: mge.device.get_allocated_memory(d) for d in args}
18 for d in args:
19 mge.device.reset_max_memory_stats(d)
20
21 def get_max(self, device):
22 return mge.device.get_max_allocated_memory(device) - self.baseline[device]
23
24
25@pytest.mark.require_ngpu(1)

Callers 3

test_mem_statsFunction · 0.85
test_borrowFunction · 0.85
test_stream_memFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_mem_statsFunction · 0.68
test_borrowFunction · 0.68
test_stream_memFunction · 0.68