From dcff7f20d5e4a1d34fc89444f5229eb88c034edd Mon Sep 17 00:00:00 2001 From: zhiqiu Date: Fri, 2 Jul 2021 02:34:28 +0000 Subject: [PATCH 1/3] enhance error message when x or y is empty in elementwise_op --- paddle/fluid/operators/elementwise/elementwise_op_function.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paddle/fluid/operators/elementwise/elementwise_op_function.h b/paddle/fluid/operators/elementwise/elementwise_op_function.h index d09e777670990a..357a43122b30cb 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op_function.h +++ b/paddle/fluid/operators/elementwise/elementwise_op_function.h @@ -252,6 +252,10 @@ void CommonForwardBroadcastCPU(const framework::Tensor *x, std::vector index_array(max_dim, 0); const T *x_data = x->data(); const T *y_data = y->data(); + PADDLE_ENFORCE_NOT_NULL(x_data, platform::errors::InvalidArgument( + "The input X should not be empty.")); + PADDLE_ENFORCE_NOT_NULL(y_data, platform::errors::InvalidArgument( + "The input Y should not be empty.")); OutType *out_data = z->mutable_data(ctx.GetPlace()); const int out_size = std::accumulate(out_dims_array, out_dims_array + max_dim, From ecc86748cefe28e61680593b97a24871977f5f8a Mon Sep 17 00:00:00 2001 From: zhiqiu Date: Fri, 2 Jul 2021 08:21:56 +0000 Subject: [PATCH 2/3] format code --- paddle/fluid/operators/elementwise/elementwise_op_function.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/operators/elementwise/elementwise_op_function.h b/paddle/fluid/operators/elementwise/elementwise_op_function.h index 357a43122b30cb..b4aed1298ae815 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op_function.h +++ b/paddle/fluid/operators/elementwise/elementwise_op_function.h @@ -255,7 +255,7 @@ void CommonForwardBroadcastCPU(const framework::Tensor *x, PADDLE_ENFORCE_NOT_NULL(x_data, platform::errors::InvalidArgument( "The input X should not be empty.")); PADDLE_ENFORCE_NOT_NULL(y_data, platform::errors::InvalidArgument( - "The input Y should not be empty.")); + "The input Y should not be empty.")); OutType *out_data = z->mutable_data(ctx.GetPlace()); const int out_size = std::accumulate(out_dims_array, out_dims_array + max_dim, From 4c6c1fb8b0ebae48c7ac2078ffebac85ba12c943 Mon Sep 17 00:00:00 2001 From: zhiqiu Date: Fri, 2 Jul 2021 08:22:03 +0000 Subject: [PATCH 3/3] format code --- paddle/fluid/operators/elementwise/elementwise_op_function.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/elementwise/elementwise_op_function.h b/paddle/fluid/operators/elementwise/elementwise_op_function.h index b4aed1298ae815..dce9a54f39a2ef 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op_function.h +++ b/paddle/fluid/operators/elementwise/elementwise_op_function.h @@ -253,9 +253,9 @@ void CommonForwardBroadcastCPU(const framework::Tensor *x, const T *x_data = x->data(); const T *y_data = y->data(); PADDLE_ENFORCE_NOT_NULL(x_data, platform::errors::InvalidArgument( - "The input X should not be empty.")); + "The input X should not be empty.")); PADDLE_ENFORCE_NOT_NULL(y_data, platform::errors::InvalidArgument( - "The input Y should not be empty.")); + "The input Y should not be empty.")); OutType *out_data = z->mutable_data(ctx.GetPlace()); const int out_size = std::accumulate(out_dims_array, out_dims_array + max_dim,