Skip to content

Commit 016bd07

Browse files
committed
Fix
1 parent 96c9b48 commit 016bd07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

paddle/phi/kernels/xpu/p_norm_kernel.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "paddle/phi/kernels/p_norm_kernel.h"
1616
#include "paddle/phi/backends/xpu/enforce_xpu.h"
1717
#include "paddle/phi/core/kernel_registry.h"
18-
18+
#include "paddle/phi/kernels/full_kernel.h"
1919
namespace phi {
2020

2121
inline void GetDims(const phi::DDim& dim,
@@ -50,6 +50,11 @@ void PNormKernel(const Context& dev_ctx,
5050
DenseTensor* out) {
5151
using XPUType = typename XPUTypeTrait<T>::Type;
5252
dev_ctx.template Alloc<T>(out);
53+
if (x.numel() == 0) {
54+
phi::Full<T, Context>(
55+
dev_ctx, phi::IntArray(common::vectorize(out->dims())), 0, out);
56+
return;
57+
}
5358
auto xdim = x.dims();
5459
if (axis < 0) axis = xdim.size() + axis;
5560
std::vector<int64_t> r_dim;

0 commit comments

Comments
 (0)