Browse Source

test(mge): disable gc in leak check

GitOrigin-RevId: b650a46e02
release-1.1
Megvii Engine Team 4 years ago
parent
commit
176268d20c
1 changed files with 10 additions and 6 deletions
  1. +10
    -6
      imperative/python/test/unit/core/test_autodiff.py

+ 10
- 6
imperative/python/test/unit/core/test_autodiff.py View File

@@ -163,12 +163,16 @@ def test_release():
def check(f): def check(f):
n = 0 n = 0
d = None d = None
for i in range(3):
f()
m = len(gc.get_objects())
d = m - n
n = m
assert d == 0
gc.disable()
try:
for i in range(3):
f()
m = len(gc.get_objects())
d = m - n
n = m
assert d == 0
finally:
gc.enable()


x = TensorWrapper([0.0]) x = TensorWrapper([0.0])
dy = TensorWrapper(np.ones_like(x.numpy())) dy = TensorWrapper(np.ones_like(x.numpy()))


Loading…
Cancel
Save