def test_no_leak_many_call_nonlazy():
# Verify no memory leaks when calling a function a lot of times
# This isn't really a unit test, you have to run it and look at top to
# see if there's a leak.
def build_graph(x, depth=5):
z = x
for d in range(depth):
z = tensor.sin(-z + 1)
return z
def time_linker(name, linker):
steps_a = 10
x = tensor.dvector()
a = build_graph(x, steps_a)
f_a = function([x], a,
mode=Mode(optimizer=None,
linker=linker()))
inp = numpy.random.rand(1000000)
for i in xrange(500):
f_a(inp)
print(1)
time_linker('vmLinker_C',
lambda: vm.VM_Linker(allow_gc=False, use_cloop=True))
print(2)
time_linker('vmLinker',
lambda: vm.VM_Linker(allow_gc=False, use_cloop=False))
评论列表
文章目录