From 00c1ef7f8a672051caea57a6b07c39d35bcae18b Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Wed, 17 Oct 2018 15:27:03 -0700 Subject: [PATCH 1/4] change printf %ld to %ld for kH and kW --- aten/src/THNN/generic/SpatialConvolutionMM.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aten/src/THNN/generic/SpatialConvolutionMM.c b/aten/src/THNN/generic/SpatialConvolutionMM.c index 9f8b8e7c90c92..9fae9ad7d409d 100644 --- a/aten/src/THNN/generic/SpatialConvolutionMM.c +++ b/aten/src/THNN/generic/SpatialConvolutionMM.c @@ -46,7 +46,7 @@ static inline void THNN_(SpatialConvolutionMM_shapeCheck)( if (exactInputHeight < kH || exactInputWidth < kW) { THError("Calculated padded input size per channel: (%ld x %ld). " - "Kernel size: (%ld x %ld). Kernel size can't be greater than actual input size", + "Kernel size: (%d x %d). Kernel size can't be greater than actual input size", exactInputHeight, exactInputWidth, kH, kW); } From 84a8c4e426ba8f88f0a8cb32e01c784f56f588db Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Wed, 17 Oct 2018 15:34:43 -0700 Subject: [PATCH 2/4] fix in cuda as well --- aten/src/THCUNN/generic/SpatialConvolutionMM.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aten/src/THCUNN/generic/SpatialConvolutionMM.cu b/aten/src/THCUNN/generic/SpatialConvolutionMM.cu index 616e9db75b650..6c5b80a6940a5 100644 --- a/aten/src/THCUNN/generic/SpatialConvolutionMM.cu +++ b/aten/src/THCUNN/generic/SpatialConvolutionMM.cu @@ -47,7 +47,7 @@ static inline void THNN_(SpatialConvolutionMM_shapeCheck)( if (exactInputHeight < kH || exactInputWidth < kW) { THError("Calculated padded input size per channel: (%ld x %ld). " - "Kernel size: (%ld x %ld). Kernel size can't be greater than actual input size", + "Kernel size: (%d x %d). Kernel size can't be greater than actual input size", exactInputHeight, exactInputWidth, kH, kW); } From 06859f5b4c0f0627916d397cafc35a828d9cc476 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Wed, 17 Oct 2018 17:22:44 -0700 Subject: [PATCH 3/4] add test case for conv2d --- test/test_nn.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_nn.py b/test/test_nn.py index 272533564b562..c25d2b3b31800 100644 --- a/test/test_nn.py +++ b/test/test_nn.py @@ -755,6 +755,13 @@ def test_invalid_conv2d(self): input = torch.empty(1, 1, 4, 4) self.assertRaises(RuntimeError, lambda: module(input)) + module = nn.Conv2d(in_channels=3, out_channels=33, kernel_size=10, stride=1, bias=True) + input = torch.randn(1, 3, 1, 1) + with self.assertRaisesRegex(RuntimeError, + 'Calculated padded input size per channel: \(1 x 1\). ' + + 'Kernel size: \(10 x 10\). Kernel size can\'t be greater than actual input size'): + module(input) + def test_invalid_conv3d(self): module = torch.nn.Conv3d(1, 1, kernel_size=3, dilation=2, stride=2) input = torch.empty(1, 1, 4, 4, 4) From a10602e3ec4f84888dada94f9779ae2a6b7bf589 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Wed, 17 Oct 2018 17:26:23 -0700 Subject: [PATCH 4/4] fix conv3d as well --- aten/src/THNN/generic/VolumetricConvolutionMM.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aten/src/THNN/generic/VolumetricConvolutionMM.c b/aten/src/THNN/generic/VolumetricConvolutionMM.c index 51b8de16b273a..03e4b92d95472 100644 --- a/aten/src/THNN/generic/VolumetricConvolutionMM.c +++ b/aten/src/THNN/generic/VolumetricConvolutionMM.c @@ -74,7 +74,7 @@ static void inline THNN_(VolumetricConvolutionMM_shapeCheck)( if (exactInputDepth < kT || exactInputHeight < kH || exactInputWidth < kW) { THError("Calculated padded input size per channel: (%ld x %ld x %ld). " - "Kernel size: (%ld x %ld x %ld). Kernel size can't be greater than actual input size", + "Kernel size: (%d x %d x %d). Kernel size can't be greater than actual input size", exactInputDepth, exactInputHeight, exactInputWidth, kT, kH, kW); }