Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aten/src/THCUNN/generic/SpatialConvolutionMM.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion aten/src/THNN/generic/SpatialConvolutionMM.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion aten/src/THNN/generic/VolumetricConvolutionMM.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 7 additions & 0 deletions test/test_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down