bug描述 Describe the Bug
conv = paddle.nn.Conv2D(in_channels=6, out_channels=8, kernel_size=[8, 8], stride=1, padding=[1, 1], dilation=[1, 1], groups=1, bias_attr=None)
input = paddle.randn([10, 6, 6, 2])
output = conv(input)
报错
Traceback (most recent call last):
File "/mnt/AA_MoCoDiff/MoCoDiff/result_extract_pytorch_paddle_fixed/pytorch-paddle-AlexNet/AlexNet-14-4/try.py", line 7, in <module>
output = conv(input)
File "/root/miniconda3/envs/myconda/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__
return self.forward(*inputs, **kwargs)
File "/root/miniconda3/envs/myconda/lib/python3.10/site-packages/paddle/nn/layer/conv.py", line 715, in forward
out = F.conv._conv_nd(
File "/root/miniconda3/envs/myconda/lib/python3.10/site-packages/paddle/nn/functional/conv.py", line 128, in _conv_nd
pre_bias = _C_ops.conv2d(
RuntimeError: (PreconditionNotMet) The meta data must be valid when call the mutable data function.
[Hint: Expected valid() == true, but received valid():0 != true:1.] (at /paddle/paddle/phi/core/dense_tensor.cc:127)
nn.Conv2D没有对kernel_size进行检查,导致运行到底层的算子代码才报错,并且没有提示信息。
但是使用同样的代码,PyTorch会报错。
conv = torch.nn.Conv2d(in_channels=6, out_channels=8, kernel_size=[8, 8], stride=1, padding=[1, 1], dilation=[1, 1], groups=1, bias=True)
input = torch.randn([10, 6, 6, 2])
output = conv(input)
报错
Traceback (most recent call last):
File "/mnt/AA_MoCoDiff/MoCoDiff/result_extract_pytorch_paddle_fixed/pytorch-paddle-AlexNet/AlexNet-14-4/try.py", line 11, in <module>
output = conv(input)
File "/root/miniconda3/envs/myconda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/root/miniconda3/envs/myconda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/root/miniconda3/envs/myconda/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 460, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/root/miniconda3/envs/myconda/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 456, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Calculated padded input size per channel: (8 x 4). Kernel size: (8 x 8). Kernel size can't be greater than actual input size
其他补充信息 Additional Supplementary Information
paddle version:2.6.1
1条答案
按热度按时间9nvpjoqh1#
感谢反馈,我们会尽快优化报错提示