提交 d6a9018a authored 作者: Vikram's avatar Vikram

Same changes for GPU. cuDNN disabled. More tests

上级 5726f9ab
......@@ -480,11 +480,11 @@ class BaseGpuCorrMM(CGpuKernelBase):
'tuple of length 2'.format(border_mode))
border = ()
for mode in border_mode:
if isinstance(mode, integer_types) and mode >= 0:
border += ((mode, mode),)
elif isinstance(mode, tuple) and len(mode) == 2 and \
if isinstance(mode, tuple) and len(mode) == 2 and \
min(mode) >= 0:
border += ((int(mode[0]), int(mode[1])),)
elif mode >= 0:
border += ((int(mode), int(mode)),)
else:
raise ValueError(
'invalid border mode {}. The tuple can only contain '
......@@ -630,13 +630,13 @@ class BaseGpuCorrMM(CGpuKernelBase):
if height:
height = '(*(npy_int*)(PyArray_DATA(%s)))' % height
else:
if ((direction != 0) and (dH != 1)) or ((direction == 1) and (padH_l == -1)):
if ((direction != 0) and (dH != 1)) or ((direction == 1) and (padH_l == -1 or padH_r == -1)):
raise ValueError("height must be given for backprop with vertical sampling or pad='half'")
height = '-1'
if width:
width = '(*(npy_int*)(PyArray_DATA(%s)))' % width
else:
if ((direction != 0) and (dW != 1)) or ((direction == 1) and (padW_l == -1)):
if ((direction != 0) and (dW != 1)) or ((direction == 1) and (padW_l == -1 or padW_r == -1)):
raise ValueError("width must be given for backprop with horizontal sampling or pad='half'")
width = '-1'
......
......@@ -3038,6 +3038,9 @@ def local_abstractconv_cudnn_graph(op, context_name, inputs, outputs):
if op.unshared:
return None
if isinstance(op.border_mode, tuple) and any(isinstance(p, tuple) for p in op.border_mode):
return None
inp1 = inputs[0]
inp2 = inputs[1]
......@@ -3134,6 +3137,8 @@ def local_abstractconv_cudnn(node):
return
if node.op.unshared:
return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
return None
if isinstance(node.op, AbstractConv2d):
return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs)
elif isinstance(node.op, AbstractConv3d):
......@@ -3150,6 +3155,8 @@ def local_abstractconv_cudnn_alt(node):
return None
if node.op.unshared:
return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
return None
inp1 = node.inputs[0]
inp2 = node.inputs[1]
......@@ -3358,6 +3365,8 @@ def local_abstractconv_gw_cudnn(node):
return
if node.op.unshared:
return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
return None
if isinstance(node.op, AbstractConv2d_gradWeights):
return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs)
elif isinstance(node.op, AbstractConv3d_gradWeights):
......@@ -3371,6 +3380,8 @@ def local_abstractconv_gi_cudnn(node):
return
if node.op.unshared:
return None
if isinstance(node.op.border_mode, tuple) and any(isinstance(p, tuple) for p in node.op.border_mode):
return None
if isinstance(node.op, AbstractConv2d_gradInputs):
return local_abstractconv_cudnn_graph(node.op, ctx, node.inputs, node.outputs)
elif isinstance(node.op, AbstractConv3d_gradInputs):
......
......@@ -12,7 +12,7 @@ from ..type import gpuarray_shared_constructor
from ..blas import GpuCorrMM, GpuCorrMM_gradWeights, GpuCorrMM_gradInputs
from .config import mode_with_gpu, mode_without_gpu, ref_cast
from theano.tensor.nnet.tests.test_abstract_conv import Grouped_conv_noOptim, TestUnsharedConv
from theano.tensor.nnet.tests.test_abstract_conv import TestAsymmetricPadding
from theano.tensor.nnet.tests.test_abstract_conv import TestAsymmetricPadding, TestCausalConv
class TestCorrMM(unittest.TestCase):
......@@ -280,3 +280,7 @@ class TestAsymmetricGpu(TestAsymmetricPadding):
conv2d_op = GpuCorrMM
conv2d_gradw_op = GpuCorrMM_gradWeights
conv2d_gradi_op = GpuCorrMM_gradInputs
class TestCausalGpuCorr(TestCausalConv):
mode = mode_with_gpu.excluding('cudnn')
......@@ -11,7 +11,7 @@ import theano.tensor as T
from theano.tests import unittest_tools as utt
from theano.tensor.nnet import corr, conv
from theano.tensor.nnet.tests.test_abstract_conv import Grouped_conv_noOptim, TestUnsharedConv
from theano.tensor.nnet.tests.test_abstract_conv import TestAsymmetricPadding
from theano.tensor.nnet.tests.test_abstract_conv import TestAsymmetricPadding, TestCausalConv
class TestCorr2D(utt.InferShapeTester):
......@@ -473,6 +473,13 @@ class TestAsymmetricCorr(TestAsymmetricPadding):
conv2d_gradi_op = corr.CorrMM_gradInputs
class TestCausalCorr(TestCausalConv):
if theano.config.mode == "FAST_COMPILE":
mode = theano.compile.get_mode("FAST_RUN").excluding('gpuarray')
else:
mode = None
if __name__ == '__main__':
t = TestCorr2D('setUp')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论