From 60bfd308ab123e4e082ea83eb9304304f7f9a9a8 Mon Sep 17 00:00:00 2001 From: Zhong Hui Date: Thu, 10 Dec 2020 21:47:47 +0800 Subject: [PATCH] fix p_norm with empty shape (#29500) fix p_norm with empty shape (#29500) --- paddle/fluid/operators/p_norm_op.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/paddle/fluid/operators/p_norm_op.cc b/paddle/fluid/operators/p_norm_op.cc index cd7a8c6d24e..426a059c2ae 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; -- GitLab