From 70100e4f9ce1441874641a5400a3e051c00f2c82 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Mon, 5 Jul 2021 13:54:44 +0800 Subject: [PATCH] Enhance error message when x or y is empty in elementwise_op (#33928) * enhance error message when x or y is empty in elementwise_op * format code * format code --- 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 d09e7776709..dce9a54f39a 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, -- GitLab