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

Function test_borrow

imperative/python/test/unit/core/test_stream.py:36–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34
35@pytest.mark.require_ngpu(1)
36def test_borrow():
37 memstat = MemStat("xpux:0", "xpux:1")
38
39 x_np = np.random.randint(2 ** 30, size=(1 * 1024 * 1024,), dtype="int32")
40 unit = x_np.size * 4
41 x0 = mge.Tensor(x_np, device="xpux:0")
42 x1 = x0.to("xpux:1", _borrow=True)
43 y = -x1
44 np.testing.assert_equal(-x_np, y.numpy())
45
46 mge._full_sync()
47 assert memstat.get_max("xpux:0") / unit < 2.1
48
49
50@pytest.mark.require_ngpu(1)

Callers

nothing calls this directly

Calls 6

toMethod · 0.95
get_maxMethod · 0.95
MemStatClass · 0.85
assert_equalMethod · 0.80
TensorMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected