未验证 提交 6e29c2da 编写于 作者: J Jack Zhou 提交者: GitHub

Error description optimize for the math dir

Error description optimize for the math dir
上级 e25bcc98
......@@ -226,8 +226,8 @@ TEST(math_funciton, set_constant) {
for (int64_t i = 0; i < t.numel(); ++i) {
PADDLE_ENFORCE_EQ(10, t.data<int>()[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<int>()[i]));
}
delete ctx;
......
......@@ -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();
......
......@@ -34,16 +34,15 @@ class Vol2ColFunctor<platform::CPUDeviceContext, T> {
const std::vector<int>& strides,
const std::vector<int>& 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<platform::CPUDeviceContext, T> {
const std::vector<int>& strides,
const std::vector<int>& 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<platform::CPUDeviceContext, T> {
((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<T>();
const T* col_data = col.data<T>();
......
......@@ -90,16 +90,14 @@ class Vol2ColFunctor<platform::CUDADeviceContext, T> {
const std::vector<int>& strides,
const std::vector<int>& 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<platform::CUDADeviceContext, T> {
const std::vector<int>& strides,
const std::vector<int>& 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<platform::CUDADeviceContext, T> {
((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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册