diff --git a/paddle/fluid/operators/math/math_function_test.cc b/paddle/fluid/operators/math/math_function_test.cc index 587823e535ac67f926fd469d2f43df536c8c88b6..3388d7edafecc4c0dd3a041316dc6f171d035319 100644 --- a/paddle/fluid/operators/math/math_function_test.cc +++ b/paddle/fluid/operators/math/math_function_test.cc @@ -226,8 +226,8 @@ TEST(math_funciton, set_constant) { for (int64_t i = 0; i < t.numel(); ++i) { PADDLE_ENFORCE_EQ(10, t.data()[i], paddle::platform::errors::InvalidArgument( - "Each value of input" - "tensor should be 10, but received %d.", + "Each value of input tensor should be 10, " + "but received %d.", t.data()[i])); } delete ctx; diff --git a/paddle/fluid/operators/math/sampler.h b/paddle/fluid/operators/math/sampler.h index de9113f2bb616b489747d8d960154f55bb988847..b90e7e1980335f1facd38738671e7986187d1ceb 100644 --- a/paddle/fluid/operators/math/sampler.h +++ b/paddle/fluid/operators/math/sampler.h @@ -33,10 +33,10 @@ namespace math { class Sampler { public: explicit Sampler(int64_t range, unsigned int seed = 0UL) : range_(range) { - PADDLE_ENFORCE_GT(range, 0, platform::errors::InvalidArgument( - "Range should be" - " greater than 0, but recevied %d.", - range)); + PADDLE_ENFORCE_GT( + range, 0, + platform::errors::InvalidArgument( + "Range should be greater than 0, but recevied %d.", range)); if (seed == 0) { std::random_device r; seed_ = r(); diff --git a/paddle/fluid/operators/math/vol2col.cc b/paddle/fluid/operators/math/vol2col.cc index c05da0062f2bab66746feb9d8ebedeca0c0f9688..794fc647172b040d4e926144a87b84eb4e5216b0 100644 --- a/paddle/fluid/operators/math/vol2col.cc +++ b/paddle/fluid/operators/math/vol2col.cc @@ -34,16 +34,15 @@ class Vol2ColFunctor { const std::vector& strides, const std::vector& paddings, framework::Tensor* col, const DataLayout data_layout) const { - PADDLE_ENFORCE_EQ( - vol.dims().size(), 4, - platform::errors::InvalidArgument("The dimension of" - " vol should be 4, but received %d.", - vol.dims().size())); - PADDLE_ENFORCE_EQ( - col->dims().size(), 7, - platform::errors::InvalidArgument("The dimension of" - "col should be 7, but received %d.", - col->dims().size())); + PADDLE_ENFORCE_EQ(vol.dims().size(), 4, + platform::errors::InvalidArgument( + "The dimension of vol should be 4, but received %d.", + vol.dims().size())); + + PADDLE_ENFORCE_EQ(col->dims().size(), 7, + platform::errors::InvalidArgument( + "The dimension of col should be 7, but received %d.", + col->dims().size())); int input_channels = (data_layout != DataLayout::kNHWC ? vol.dims()[0] : vol.dims()[3]); @@ -152,16 +151,15 @@ class Col2VolFunctor { const std::vector& strides, const std::vector& paddings, framework::Tensor* vol, const DataLayout data_layout) const { - PADDLE_ENFORCE_EQ( - vol->dims().size(), 4, - platform::errors::InvalidArgument("The dimension of vol" - " should be 4, but received %d.", - vol->dims().size())); - PADDLE_ENFORCE_EQ( - col.dims().size(), 7, - platform::errors::InvalidArgument("The dimension of col" - " should be 7, but received %d.", - col.dims().size())); + PADDLE_ENFORCE_EQ(vol->dims().size(), 4, + platform::errors::InvalidArgument( + "The dimension of vol should be 4, but received %d.", + vol->dims().size())); + + PADDLE_ENFORCE_EQ(col.dims().size(), 7, + platform::errors::InvalidArgument( + "The dimension of col should be 7, but received %d.", + col.dims().size())); int input_channels = (data_layout != DataLayout::kNHWC ? vol->dims()[0] : vol->dims()[3]); @@ -192,29 +190,29 @@ class Col2VolFunctor { ((dilations[0] * (filter_depth - 1) + 1))) / strides[0] + 1; - PADDLE_ENFORCE_EQ(input_depth_tmp, output_depth, - platform::errors::InvalidArgument( - "input_depth(%d)" - " and output_depth(%d) are mismatching.", - input_depth_tmp, output_depth)); + PADDLE_ENFORCE_EQ( + input_depth_tmp, output_depth, + platform::errors::InvalidArgument( + "input_depth(%d) and output_depth(%d) are mismatching.", + input_depth_tmp, output_depth)); auto input_height_tmp = (input_height + pad_h_up + pad_h_down - ((dilations[1] * (filter_height - 1) + 1))) / strides[1] + 1; - PADDLE_ENFORCE_EQ(input_height_tmp, output_height, - platform::errors::InvalidArgument( - "input_height(%d)" - " and output_height(%d) are mismatching.", - input_height_tmp, output_height)); + PADDLE_ENFORCE_EQ( + input_height_tmp, output_height, + platform::errors::InvalidArgument( + "input_height(%d) and output_height(%d) are mismatching.", + input_height_tmp, output_height)); auto input_width_tmp = (input_width + pad_w_left + pad_w_right - ((dilations[2] * (filter_width - 1) + 1))) / strides[2] + 1; - PADDLE_ENFORCE_EQ(input_width_tmp, output_width, - platform::errors::InvalidArgument( - "input_width(%d)" - " and output_width(%d) are mismatching.", - input_width_tmp, output_width)); + PADDLE_ENFORCE_EQ( + input_width_tmp, output_width, + platform::errors::InvalidArgument( + "input_width(%d) and output_width(%d) are mismatching.", + input_width_tmp, output_width)); T* vol_data = vol->data(); const T* col_data = col.data(); diff --git a/paddle/fluid/operators/math/vol2col.cu b/paddle/fluid/operators/math/vol2col.cu index fe5a600909893b8313d470923ef4d43eae155e76..eca39e919737210267d7af1856903d3e1fc697d1 100644 --- a/paddle/fluid/operators/math/vol2col.cu +++ b/paddle/fluid/operators/math/vol2col.cu @@ -90,16 +90,14 @@ class Vol2ColFunctor { const std::vector& strides, const std::vector& paddings, framework::Tensor* col, const DataLayout data_layout) const { - PADDLE_ENFORCE_EQ( - vol.dims().size(), 4, - platform::errors::InvalidArgument("The dimension of" - " vol should be 4, but received %d.", - vol.dims().size())); - PADDLE_ENFORCE_EQ( - col->dims().size(), 7, - platform::errors::InvalidArgument("The dimension of" - "col should be 7, but received %d.", - col->dims().size())); + PADDLE_ENFORCE_EQ(vol.dims().size(), 4, + platform::errors::InvalidArgument( + "The dimension of vol should be 4, but received %d.", + vol.dims().size())); + PADDLE_ENFORCE_EQ(col->dims().size(), 7, + platform::errors::InvalidArgument( + "The dimension of col should be 7, but received %d.", + col->dims().size())); int input_channels = (data_layout != DataLayout::kNHWC ? vol.dims()[0] : vol.dims()[3]); @@ -253,16 +251,14 @@ class Col2VolFunctor { const std::vector& strides, const std::vector& paddings, framework::Tensor* vol, const DataLayout data_layout) const { - PADDLE_ENFORCE_EQ( - vol->dims().size(), 4, - platform::errors::InvalidArgument("The dimension of vol" - " should be 4, but received %d.", - vol->dims().size())); - PADDLE_ENFORCE_EQ( - col.dims().size(), 7, - platform::errors::InvalidArgument("The dimension of col" - " should be 7, but received %d.", - col.dims().size())); + PADDLE_ENFORCE_EQ(vol->dims().size(), 4, + platform::errors::InvalidArgument( + "The dimension of vol should be 4, but received %d.", + vol->dims().size())); + PADDLE_ENFORCE_EQ(col.dims().size(), 7, + platform::errors::InvalidArgument( + "The dimension of col should be 7, but received %d.", + col.dims().size())); int input_channels = (data_layout != DataLayout::kNHWC ? vol->dims()[0] : vol->dims()[3]); @@ -291,29 +287,29 @@ class Col2VolFunctor { ((dilations[0] * (filter_depth - 1) + 1))) / strides[0] + 1; - PADDLE_ENFORCE_EQ(input_depth_tmp, output_depth, - platform::errors::InvalidArgument( - "input_depth(%d)" - " and output_depth(%d) are mismatching.", - input_depth_tmp, output_depth)); + PADDLE_ENFORCE_EQ( + input_depth_tmp, output_depth, + platform::errors::InvalidArgument( + "input_depth(%d) and output_depth(%d) are mismatching.", + input_depth_tmp, output_depth)); auto input_height_tmp = (input_height + pad_h_up + pad_h_down - ((dilations[1] * (filter_height - 1) + 1))) / strides[1] + 1; - PADDLE_ENFORCE_EQ(input_height_tmp, output_height, - platform::errors::InvalidArgument( - "input_height(%d)" - " and output_height(%d) are mismatching.", - input_height_tmp, output_height)); + PADDLE_ENFORCE_EQ( + input_height_tmp, output_height, + platform::errors::InvalidArgument( + "input_height(%d) and output_height(%d) are mismatching.", + input_height_tmp, output_height)); auto input_width_tmp = (input_width + pad_w_left + pad_w_right - ((dilations[2] * (filter_width - 1) + 1))) / strides[2] + 1; - PADDLE_ENFORCE_EQ(input_width_tmp, output_width, - platform::errors::InvalidArgument( - "input_width(%d)" - " and output_width(%d) are mismatching.", - input_width_tmp, output_width)); + PADDLE_ENFORCE_EQ( + input_width_tmp, output_width, + platform::errors::InvalidArgument( + "input_width(%d) and output_width(%d) are mismatching.", + input_width_tmp, output_width)); int num_kernels = input_channels * input_depth * input_height * input_width;