Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paddle/fluid/inference/tensorrt/op_teller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2806,8 +2806,8 @@ struct SimpleOpTypeSetTeller : public Teller {
}
bool asvector = PADDLE_GET_CONST(bool, desc.GetAttr("asvector"));
int axis = PADDLE_GET_CONST(int, desc.GetAttr("axis"));
float porder = PADDLE_GET_CONST(float, desc.GetAttr("porder"));
if (asvector || porder != 2.0f || axis != -1) {
double porder = PADDLE_GET_CONST(double, desc.GetAttr("porder"));
if (asvector || porder != 2.0 || axis != -1) {
VLOG(3) << op_type
<< " op only support asvector=False, porder=2, axis = -1.";
return false;
Expand Down
6 changes: 6 additions & 0 deletions paddle/fluid/pir/serialize_deserialize/patch/4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ op_patches:
object : using_weighted_combine
type : pir::BoolAttribute
data : "false"
- op_name : pd_op.p_norm
actions :
- action : modify_attr
object : porder
type : pir::DoubleAttribute
data : 2
- op_name : pd_op.layer_norm
actions:
- action : modify_attr
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/infermeta/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3781,7 +3781,7 @@ void PixelUnshuffleInferMeta(const MetaTensor& x,
}

void PNormInferMeta(const MetaTensor& x,
float porder,
double porder,
int axis,
float epsilon,
bool keepdim,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/infermeta/unary.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ PADDLE_API void PixelUnshuffleInferMeta(const MetaTensor& x,
MetaTensor* out);

PADDLE_API void PNormInferMeta(const MetaTensor& x,
float porder,
double porder,
int axis,
float epsilon,
bool keepdim,
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/cpu/p_norm_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void PNormGradKernel(const Context& dev_ctx,
const DenseTensor& x,
const DenseTensor& out,
const DenseTensor& out_grad,
float porder,
double porder,
int axis,
float epsilon,
bool keepdim UNUSED,
Expand Down Expand Up @@ -88,8 +88,8 @@ void PNormGradKernel(const Context& dev_ctx,
xr.sign() * norm_dy.broadcast(bcast);
} else {
dx.device(*place) =
(xr.abs()).pow(porder - 1.0f) /
((norm.broadcast(bcast)).pow(porder - 1.0f) + xr.constant(eps));
(xr.abs()).pow(porder - 1.0) /
((norm.broadcast(bcast)).pow(porder - 1.0) + xr.constant(eps));
dx.device(*place) = dx * norm_dy.broadcast(bcast) * xr.sign();
}
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/cpu/p_norm_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ inline void GetDims(
template <typename T, typename Context>
void PNormKernel(const Context& dev_ctx,
const DenseTensor& x,
float porder,
double porder,
int axis,
float epsilon UNUSED,
bool keepdim UNUSED,
Expand Down Expand Up @@ -90,7 +90,7 @@ void PNormKernel(const Context& dev_ctx,
} else if (porder == -INFINITY) {
norm.device(*place) = xr.abs().minimum(rdim);
} else {
norm.device(*place) = xr.abs().pow(porder).sum(rdim).pow(1.0f / porder);
norm.device(*place) = xr.abs().pow(porder).sum(rdim).pow(1.0 / porder);
}
}
} // namespace phi
Expand Down
Loading
Loading