提交 cbb02686 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

PEP8 fixes

上级 8a855c90
...@@ -181,8 +181,8 @@ def test_speed_lazy(): ...@@ -181,8 +181,8 @@ def test_speed_lazy():
run_memory_usage_tests = False run_memory_usage_tests = False
if run_memory_usage_tests: if run_memory_usage_tests:
# these are not normal unit tests, do not run them as part of standard # these are not normal unit tests, do not run them as part of standard
# suite. I ran them while looking at top, and stopped when memory usage was # suite. I ran them while looking at top, and stopped when memory usage
# stable. # was stable.
def test_leak2(): def test_leak2():
import theano.sandbox.cuda as cuda import theano.sandbox.cuda as cuda
for i in xrange(1000000): for i in xrange(1000000):
...@@ -199,13 +199,13 @@ if run_memory_usage_tests: ...@@ -199,13 +199,13 @@ if run_memory_usage_tests:
def test_no_leak_many_graphs(): def test_no_leak_many_graphs():
# Verify no memory leaks when creating and deleting a lot of functions # Verify no memory leaks when creating and deleting a lot of functions
# This isn't really a unit test, you have to run it and look at top to see # This isn't really a unit test, you have to run it and look at top to
# if there's a leak # see if there's a leak
for i in xrange(10000): for i in xrange(10000):
x = tensor.vector() x = tensor.vector()
z = x z = x
for d in range(10): for d in range(10):
z = tensor.sin(-z+ 1) z = tensor.sin(-z + 1)
f = function([x], z, mode=Mode(optimizer=None, linker='cvm')) f = function([x], z, mode=Mode(optimizer=None, linker='cvm'))
if not i % 100: if not i % 100:
...@@ -222,13 +222,13 @@ if run_memory_usage_tests: ...@@ -222,13 +222,13 @@ if run_memory_usage_tests:
def test_no_leak_many_call_lazy(): def test_no_leak_many_call_lazy():
# Verify no memory leaks when calling a function a lot of times # 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 # This isn't really a unit test, you have to run it and look at top to
# if there's a leak # see if there's a leak
def build_graph(x, depth=5): def build_graph(x, depth=5):
z = x z = x
for d in range(depth): for d in range(depth):
z = ifelse(z> 0, -z, z) z = ifelse(z > 0, -z, z)
return z return z
def time_linker(name, linker): def time_linker(name, linker):
...@@ -242,7 +242,7 @@ if run_memory_usage_tests: ...@@ -242,7 +242,7 @@ if run_memory_usage_tests:
for i in xrange(100000): for i in xrange(100000):
f_a([2.0]) f_a([2.0])
if 0: # this doesn't seem to work, prints 0 for everything if 0: # this doesn't seem to work, prints 0 for everything
import resource import resource
pre = resource.getrusage(resource.RUSAGE_SELF) pre = resource.getrusage(resource.RUSAGE_SELF)
post = resource.getrusage(resource.RUSAGE_SELF) post = resource.getrusage(resource.RUSAGE_SELF)
...@@ -250,24 +250,25 @@ if run_memory_usage_tests: ...@@ -250,24 +250,25 @@ if run_memory_usage_tests:
print pre.ru_idrss, post.ru_idrss print pre.ru_idrss, post.ru_idrss
print pre.ru_maxrss, post.ru_maxrss print pre.ru_maxrss, post.ru_maxrss
time_linker('vmLinker_C', lambda : vm.VM_Linker(allow_gc=False, use_cloop=True)) time_linker('vmLinker_C',
lambda: vm.VM_Linker(allow_gc=False, use_cloop=True))
def test_no_leak_many_call_nonlazy(): def test_no_leak_many_call_nonlazy():
# Verify no memory leaks when calling a function a lot of times # 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 # This isn't really a unit test, you have to run it and look at top to
# if there's a leak # see if there's a leak.
def build_graph(x, depth=5): def build_graph(x, depth=5):
z = x z = x
for d in range(depth): for d in range(depth):
z = tensor.sin(-z+1) z = tensor.sin(-z + 1)
return z return z
def time_linker(name, linker): def time_linker(name, linker):
steps_a = 10 steps_a = 10
x = tensor.vector() x = tensor.vector()
a = build_graph(x,steps_a) a = build_graph(x, steps_a)
f_a = function([x], a, f_a = function([x], a,
mode=Mode(optimizer=None, mode=Mode(optimizer=None,
...@@ -276,7 +277,8 @@ if run_memory_usage_tests: ...@@ -276,7 +277,8 @@ if run_memory_usage_tests:
for i in xrange(500000): for i in xrange(500000):
f_a([2.0]) f_a([2.0])
time_linker('vmLinker_C', lambda : vm.VM_Linker(allow_gc=False, use_cloop=True)) time_linker('vmLinker_C',
lambda: vm.VM_Linker(allow_gc=False, use_cloop=True))
class RunOnce(theano.Op): class RunOnce(theano.Op):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论