diff --git a/paddle/fluid/operators/p_norm_op.cc b/paddle/fluid/operators/p_norm_op.cc index cd7a8c6d24eaaca096b630b74dd7cd1bb9d35d09..426a059c2aea1dfb2f17ebf4dbe6ff9a9f13b10a 100644 --- a/paddle/fluid/operators/p_norm_op.cc +++ b/paddle/fluid/operators/p_norm_op.cc @@ -116,6 +116,9 @@ class PnormOp : public framework::OperatorWithKernel { for (int i = 0; i < x_dim.size(); ++i) { if (i != axis) reduce_dims.emplace_back(x_dim[i]); } + if (reduce_dims.size() == 0) { + reduce_dims.emplace_back(1); + } } x_dim[axis] = 1;