提交 d3687dee authored 作者: Ian Goodfellow's avatar Ian Goodfellow

test_max tests now do tests with 0 shape

上级 0899d978
...@@ -9,6 +9,7 @@ from theano import tensor ...@@ -9,6 +9,7 @@ from theano import tensor
import numpy import numpy
import theano import theano
import theano.tensor as T import theano.tensor as T
from numpy.testing.noseclasses import KnownFailureTest
# Skip test if cuda_ndarray is not available. # Skip test if cuda_ndarray is not available.
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
...@@ -201,6 +202,8 @@ def test_max(): ...@@ -201,6 +202,8 @@ def test_max():
gpu_pattern = tuple(gpu_pattern) gpu_pattern = tuple(gpu_pattern)
return gpu_pattern return gpu_pattern
known_fail = False
for shape, pattern in [((1,1),(1,)), for shape, pattern in [((1,1),(1,)),
((1,0),(1,)), ((1,0),(1,)),
((0,1),(1,)), ((0,1),(1,)),
...@@ -272,6 +275,15 @@ def test_max(): ...@@ -272,6 +275,15 @@ def test_max():
except ValueError, e: except ValueError, e:
exc = e exc = e
f_caused_value_error = True f_caused_value_error = True
except RuntimeError:
if (shape, pattern) in [((1,0),(1,)),
((0,1),(1,)),
((0,0),(1,)),
((0,0,0),(1,2)),
((0,0,0,0),(1,2,3))]:
known_fail = True
continue
f2 = theano.function([a], b, mode=mode_without_gpu) f2 = theano.function([a], b, mode=mode_without_gpu)
try: try:
f2_out = f2(val) f2_out = f2(val)
...@@ -304,7 +316,8 @@ def test_max(): ...@@ -304,7 +316,8 @@ def test_max():
continue continue
if val.size == 0: if val.size == 0:
assert f2(val) == f(val), ('shape', shape, 'pattern', pattern) assert f2(val).size == f(val).size
assert f2(val).shape == f(val).shape
else: else:
try: try:
#We raise the error threashold as we sum big matrix #We raise the error threashold as we sum big matrix
...@@ -402,6 +415,10 @@ def test_max(): ...@@ -402,6 +415,10 @@ def test_max():
'pattern', pattern, 'pattern', pattern,
sum([shape[i] for i in pattern])) sum([shape[i] for i in pattern]))
if known_fail:
raise KnownFailureTest("GpuCAReduce does not handle some shapes"
" with 0s in them correctly.")
def test_flatten(): def test_flatten():
x = cuda.fmatrix('x') x = cuda.fmatrix('x')
f = theano.function([x], x.flatten()) f = theano.function([x], x.flatten())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论