提交 8b6c3291 authored 作者: Frederic Bastien's avatar Frederic Bastien

make the GpuElemwise return the same error as Elemwise when the shape mismatch.…

make the GpuElemwise return the same error as Elemwise when the shape mismatch. Modif test for this.
上级 a7a8c1c0
...@@ -37,7 +37,7 @@ def get_str_list_logical_scalar(node, value_str='ii_i%i_value', data_str='ii_i%i ...@@ -37,7 +37,7 @@ def get_str_list_logical_scalar(node, value_str='ii_i%i_value', data_str='ii_i%i
class NaiveAlgo(object): class NaiveAlgo(object):
verbose = 0 # 1, 2 or 3 for more verbose output. verbose = 0 # 1, 2 or 3 for more verbose output.
cache_version = () cache_version = ()
cache_version = ('debug', 11, verbose) cache_version = ('debug', 12, verbose)
def __init__(self, scalar_op, sync=True): def __init__(self, scalar_op, sync=True):
""" """
...@@ -855,7 +855,7 @@ nd_collapse_[i]=0; ...@@ -855,7 +855,7 @@ nd_collapse_[i]=0;
if ((!(broadcasts_%(iname)s[i] && CudaNdarray_HOST_DIMS(%(iname)s)[i] == 1))&& (dims[i] != CudaNdarray_HOST_DIMS(%(iname)s)[i])) if ((!(broadcasts_%(iname)s[i] && CudaNdarray_HOST_DIMS(%(iname)s)[i] == 1))&& (dims[i] != CudaNdarray_HOST_DIMS(%(iname)s)[i]))
{ {
//std::cerr << "C_CODE %(opname)s checking input %(iname)s failed\\n"; //std::cerr << "C_CODE %(opname)s checking input %(iname)s failed\\n";
PyErr_Format(PyExc_TypeError, "GpuElemwise input has incompatible dim[%%i] == %%i, where output has size %%i", PyErr_Format(PyExc_ValueError, "GpuElemwise. Input dimension mis-match.[%%i] == %%i, where output has size %%i",
i, i,
CudaNdarray_HOST_DIMS(%(iname)s)[i], CudaNdarray_HOST_DIMS(%(iname)s)[i],
dims[i] dims[i]
......
...@@ -213,10 +213,15 @@ def test_elemwise_bad_broadcast(): ...@@ -213,10 +213,15 @@ def test_elemwise_bad_broadcast():
x = cuda.fmatrix('x') x = cuda.fmatrix('x')
y = cuda.fmatrix('y') y = cuda.fmatrix('y')
f = theano.function([x, y], x * y) f = theano.function([x, y], x * y, mode=mode_with_gpu)
print f.maker.env.toposort()
assert len(f.maker.env.toposort())==2
assert isinstance(f.maker.env.toposort()[0].op, cuda.GpuElemwise)
assert f.maker.env.toposort()[1].op==cuda.host_from_gpu
try: try:
f(rand_cuda_ndarray((10, 3)), rand_cuda_ndarray((10, 1))) f(rand_cuda_ndarray((10, 3)), rand_cuda_ndarray((10, 1)))
except TypeError: except ValueError:
pass pass
else: else:
raise Exception("Theano should have raised an error") raise Exception("Theano should have raised an error")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论