提交 46f64a65 authored 作者: Arjun Jain's avatar Arjun Jain

Merge commit 'refs/pullreqs/origin/pr/2' into conv_gemm after Fred's commit…

Merge commit 'refs/pullreqs/origin/pr/2' into conv_gemm after Fred's commit which said valid finally works.
...@@ -103,21 +103,24 @@ CudaNdarray* validMM(const CudaNdarray *input, ...@@ -103,21 +103,24 @@ CudaNdarray* validMM(const CudaNdarray *input,
// filters: (number of filters, nInputPlane, rows, columns) // filters: (number of filters, nInputPlane, rows, columns)
int nOutputPlane = CudaNdarray_HOST_DIMS(weight)[0]; int nOutputPlane = CudaNdarray_HOST_DIMS(weight)[0];
long batchSize = CudaNdarray_HOST_DIMS(input)[0]; long batchSize = CudaNdarray_HOST_DIMS(input)[0];
if (kW != kH){ if (CudaNdarray_HOST_DIMS(input)[2] != CudaNdarray_HOST_DIMS(input)[3]){
PyErr_SetString(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"GpuConvMM support only square kernel\n" "GpuConvMM support only square images. Got %dx%d images\n",
CudaNdarray_HOST_DIMS(input)[2],
CudaNdarray_HOST_DIMS(input)[3]
); );
return NULL; return NULL;
} }
if (kW != kH){ if (kW != kH){
PyErr_SetString(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"GpuConvMM support only square images\n" "GpuConvMM support only square kernel. Got %dx%d kernel\n",
kW, kH
); );
return NULL; return NULL;
} }
if (CudaNdarray_HOST_DIMS(input)[1] != CudaNdarray_HOST_DIMS(weight)[1]){ if (CudaNdarray_HOST_DIMS(input)[1] != CudaNdarray_HOST_DIMS(weight)[1]){
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"GpuConvMM support only square images\n" "GpuConvMM images and kernel must have the same stack size\n"
); );
return NULL; return NULL;
} }
......
...@@ -1288,7 +1288,6 @@ def local_conv_gemm(node): ...@@ -1288,7 +1288,6 @@ def local_conv_gemm(node):
if (isinstance(node.op, GpuConv) and if (isinstance(node.op, GpuConv) and
node.op.border_mode == 'valid' and node.op.border_mode == 'valid' and
node.op.subsample == (1, 1)): node.op.subsample == (1, 1)):
print "WARNING, YOU ARE USING BUGGED CODE!"
img, kern = node.inputs img, kern = node.inputs
img = gpu_contiguous(img) img = gpu_contiguous(img)
kern = kern[:, :, ::-1, ::-1] kern = kern[:, :, ::-1, ::-1]
......
...@@ -637,9 +637,15 @@ def test_valid(): ...@@ -637,9 +637,15 @@ def test_valid():
mode = theano_mode.including("conv_gemm") mode = theano_mode.including("conv_gemm")
# Remove case not implemented version = [-1]
shapes = [shp for shp in shapes if shp[1][2] == shp[1][3]] # Remove case not supported
shapes = [shp for shp in shapes if shp[0][2] == shp[0][3]] # Add tests with strided inputs by still square images and filters.
shapes += get_shapes2(scales_img=(2, 2), img_stride=(2, 2))
shapes += get_shapes2(scales_kern=(2, 2), kern_stride=(2, 2))
# Keep only tests with square images and filters even with inputs strides
shapes = [shp for shp in shapes if (
shp[0][2]/shp[3][0] == shp[0][3]/shp[3][1] and
shp[1][2]/shp[4][0] == shp[1][3]/shp[4][1])]
exec_conv(version, shapes, verbose, random, 'valid', exec_conv(version, shapes, verbose, random, 'valid',
print_=print_, ones=ones, rtol=1.1e-5, print_=print_, ones=ones, rtol=1.1e-5,
theano_mode=mode, cls=cuda.blas.GpuConvMM) theano_mode=mode, cls=cuda.blas.GpuConvMM)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论