Skip to content

Commit

Permalink
Enhance error message when x or y is empty in elementwise_op (#33928)
Browse files Browse the repository at this point in the history
* enhance error message when x or y is empty in elementwise_op

* format code

* format code
  • Loading branch information
zhiqiu authored Jul 5, 2021
1 parent 1cfa105 commit 70100e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions paddle/fluid/operators/elementwise/elementwise_op_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ void CommonForwardBroadcastCPU(const framework::Tensor *x,
std::vector<int> index_array(max_dim, 0);
const T *x_data = x->data<T>();
const T *y_data = y->data<T>();
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<OutType>(ctx.GetPlace());

const int out_size = std::accumulate(out_dims_array, out_dims_array + max_dim,
Expand Down

0 comments on commit 70100e4

Please sign in to comment.