提交 938ccc88 authored 作者: Roy Xue's avatar Roy Xue

new test_ifelse() function

上级 61fdba77
"""
Tests of the ifelse crash
"""
\ No newline at end of file
...@@ -8,6 +8,7 @@ import numpy ...@@ -8,6 +8,7 @@ import numpy
import theano import theano
import theano.tensor as T import theano.tensor as T
from theano.ifelse import ifelse
def test_profiling(): def test_profiling():
...@@ -55,5 +56,47 @@ def test_profiling(): ...@@ -55,5 +56,47 @@ def test_profiling():
theano.config.profiling.min_peak_memory = config3 theano.config.profiling.min_peak_memory = config3
def test_ifelse():
config1 = theano.config.profile
config2 = theano.config.profile_memory
try:
theano.config.profile = True
theano.config.profile_memory = True
a,b = T.scalars('a', 'b')
x,y = T.scalars('x', 'y')
z = ifelse(T.lt(a, b), x*2, y*2)
p = theano.ProfileStats(False)
if theano.config.mode in ["DebugMode", "DEBUG_MODE", "FAST_COMPILE"]:
m = "FAST_RUN"
else:
m = None
f_ifelse = theano.function([a, b, x, y], z, profile=p, name="test_ifelse",
mode=m)
val1 = 0.
val2 = 1.
big_mat1 = 10
big_mat2 = 11
out = f_ifelse(val1, val2, big_mat1, big_mat2)
print out
buf = StringIO.StringIO()
f_ifelse.profile.summary(buf)
finally:
theano.config.profile = config1
theano.config.profile_memory = config2
if __name__ == '__main__': if __name__ == '__main__':
test_profiling() test_profiling()
test_ifelse()
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论