diff --git a/paddle/fluid/operators/elementwise/elementwise_op_function.h b/paddle/fluid/operators/elementwise/elementwise_op_function.h index d09e777670990a818c7a07bba9b800b1cb331566..dce9a54f39a2ef629fcddba0da3299e4bdebc7fa 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,