PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
22.23k stars 5.58k forks source link

Converting bool input to float32 and feeding it into convolution results in a core dump #68963

Open PhyllisJi opened 6 days ago

PhyllisJi commented 6 days ago

bug描述 Describe the Bug

import paddle
import paddle.nn as nn
import numpy as np

class Model_1729302669(nn.Layer):
    def __init__(self):
        super(Model_1729302669, self).__init__()
        self.conv8_mutated = paddle.nn.Conv2D(in_channels=6, out_channels=6, kernel_size=[3, 3], stride=[2, 2],
                                              padding=[1, 1], dilation=[6, 4], groups=6, bias_attr=None)

    def forward(self, input):
        conv8_output = self.conv8_mutated(input)
        return conv8_output

random_array = np.random.rand(1, 6, 21, 4) > 0.5
random_input = random_array.astype(np.float32)
print(random_input)
paddle.set_device('gpu')
paddle_random_model = Model_1729302669()
my_input = paddle.to_tensor(random_input)
paddle_random_output = paddle_random_model(my_input)
print(paddle_random_output)

其他补充信息 Additional Supplementary Information

PaddlePaddle 2.6.1 Output:

--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   paddle::pybind::eager_api_depthwise_conv2d(_object*, _object*, _object*)
1   depthwise_conv2d_ad_func(paddle::Tensor const&, paddle::Tensor const&, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::string, int, std::vector<int, std::allocator<int> >, std::string)
2   paddle::experimental::depthwise_conv2d(paddle::Tensor const&, paddle::Tensor const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::string const&, int, std::vector<int, std::allocator<int> > const&, std::string const&)
3   void phi::DepthwiseConvKernel<float, phi::GPUContext>(phi::GPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::string const&, int, std::vector<int, std::allocator<int> > const&, std::string const&, phi::DenseTensor*)
4   paddle::operators::math::DepthwiseConvFunctor<phi::GPUContext, float, false>::operator()(phi::GPUContext const&, phi::DenseTensor const&, phi::DenseTensor const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, phi::DenseTensor*, common::DataLayout)

----------------------
Error Message Summary:
----------------------
FatalError: `Erroneous arithmetic operation` is detected by the operating system.
  [TimeInfo: *** Aborted at 1729863482 (unix time) try "date -d @1729863482" if you are using GNU date ***]
  [SignalInfo: *** SIGFPE (@0x7fe00d5b519f) received by PID 443 (TID 0x7fe09e6264c0) from PID 224088479 ***]

Floating point exception (core dumped)
danleifeng commented 3 days ago

https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/nn/Conv2D_cn.html#conv2d you can read the api document. Most likely it's not a matter of bool type.

random_array = np.random.rand(1, 6, 21, 4)
random_input = random_array.astype(np.float32)
print(random_input)
paddle.set_device('gpu')
paddle_random_model = Model_1729302669()
my_input = paddle.to_tensor(random_input)
paddle_random_output = paddle_random_model(my_input)
print(paddle_random_output)

change random_array will also cause the same error

PhyllisJi commented 3 days ago

https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/nn/Conv2D_cn.html#conv2d you can read the api document. Most likely it's not a matter of bool type.

random_array = np.random.rand(1, 6, 21, 4)
random_input = random_array.astype(np.float32)
print(random_input)
paddle.set_device('gpu')
paddle_random_model = Model_1729302669()
my_input = paddle.to_tensor(random_input)
paddle_random_output = paddle_random_model(my_input)
print(paddle_random_output)

change random_array will also cause the same error

Yes, we are still getting the crash by converting the bool type to float32. Can you tell me why? I think it's a bug that occurs when paddle doesn't handle exceptions well.