提交 70e35eb5 authored 作者: Matthew Willson's avatar Matthew Willson

Remove the restriction on zero target dimensions when reshaping a CudaNdarray

上级 e9e94b4c
......@@ -871,8 +871,8 @@ PyObject * CudaNdarray_Reshape(CudaNdarray * self, PyObject * shape)
free(rval_dims);
return NULL;
}
if(rval_dims[i]<=0){
PyErr_Format(PyExc_ValueError, "Reshape has invalid dimension %i (must be >0)",rval_dims[i]);
if(rval_dims[i]<0){
PyErr_Format(PyExc_ValueError, "Reshape has invalid dimension %i (must be >=0)",rval_dims[i]);
free(rval_dims);
return NULL;
}
......
......@@ -374,6 +374,11 @@ def test_reshape():
except ValueError:
pass
# Test zero dimensions are allowed
x = T.vector('x')
f_reshp = theano.function([x], x.reshape((0,100)), mode=mode_with_gpu)
assert f_reshp(numpy.ndarray((0,), dtype='float32')).shape == (0,100)
def test_alloc_empty():
# Test that we allocated correctly
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论