未验证 提交 2d59aa09 编写于 作者: 张春乔 提交者: GitHub

fix the div 0 error of deform_conv2d (#49962)

上级 0111a354
......@@ -441,6 +441,23 @@ class TestModulatedDeformableConvInvalidInput(unittest.TestCase):
self.assertRaises(ValueError, test_invalid_filter)
def test_invalid_groups():
paddle.enable_static()
input = paddle.static.data(
name='input_groups', shape=[1, 1, 1, 1], dtype='float32'
)
offset = paddle.static.data(
name='offset_groups', shape=[1, 1], dtype='float32'
)
mask = paddle.static.data(
name='mask_groups', shape=[1], dtype='float32'
)
paddle.static.nn.deform_conv2d(
input, offset, mask, 1, 1, padding=1, groups=0
)
self.assertRaises(ValueError, test_invalid_groups)
class TestDeformConv2DAPI(unittest.TestCase):
def test_api(self):
......
......@@ -2255,6 +2255,8 @@ def deformable_conv(
if groups is None:
num_filter_channels = num_channels
else:
if groups == 0:
raise ValueError("groups should not be 0.")
if num_channels % groups != 0:
raise ValueError("num_channels must be divisible by groups.")
num_filter_channels = num_channels // groups
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册