Skip to content

Commit

Permalink
support auto generate for p_norm (PaddlePaddle#51590)
Browse files Browse the repository at this point in the history
* supoort auto generate p_norm

* fix bug in backward
  • Loading branch information
RedContritio authored Mar 22, 2023
1 parent ec877d1 commit 2b98993
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 184 deletions.
139 changes: 0 additions & 139 deletions paddle/fluid/operators/p_norm_op.cc

This file was deleted.

10 changes: 10 additions & 0 deletions paddle/phi/api/yaml/backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,16 @@
func : overlap_add_grad
data_type : x

- backward_op : p_norm_grad
forward : p_norm(Tensor x, float porder=2, int axis=-1, float epsilon=1.0e-12f, bool keepdim=false, bool asvector=false) -> Tensor(out)
args : (Tensor x, Tensor out, Tensor out_grad, float porder, int axis, float epsilon, bool keepdim, bool asvector)
output : Tensor(x_grad)
infer_meta :
func : GeneralUnaryGradInferMeta
param: [x]
kernel :
func : p_norm_grad

- backward_op : pixel_shuffle_grad
forward : pixel_shuffle (Tensor x, int upscale_factor=1, str data_format="NCHW") -> Tensor(out)
args : (Tensor out_grad, int upscale_factor, str data_format)
Expand Down
10 changes: 0 additions & 10 deletions paddle/phi/api/yaml/legacy_backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -863,16 +863,6 @@
kernel :
func : norm_grad

- backward_op : p_norm_grad
forward : p_norm(Tensor x, float porder, int axis, float epsilon, bool keepdim, bool asvector=false) -> Tensor(out)
args : (Tensor x, Tensor out, Tensor out_grad, float porder, int axis, float epsilon, bool keepdim, bool asvector)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param: [x]
kernel :
func : p_norm_grad

- backward_op : pad3d_double_grad
forward : pad3d_grad(Tensor x, Tensor grad_out, IntArray paddings, str mode, float pad_value, str data_format) -> Tensor(grad_x)
args : (Tensor grad_x_grad, IntArray paddings, str mode, float pad_value, str data_format)
Expand Down
9 changes: 0 additions & 9 deletions paddle/phi/api/yaml/legacy_ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1235,15 +1235,6 @@
output : Tensor(out)
invoke : full_like(x, 1, dtype, place)

- op : p_norm
args : (Tensor x, float porder, int axis, float epsilon, bool keepdim, bool asvector=false)
output : Tensor(out)
infer_meta :
func : PNormInferMeta
kernel :
func : p_norm
backward : p_norm_grad

- op : pad
args : (Tensor x, int[] paddings, Scalar pad_value)
output : Tensor
Expand Down
7 changes: 7 additions & 0 deletions paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,13 @@
outputs :
out : Out

- op : p_norm
backward: p_norm_grad
inputs :
x : X
outputs :
out : Out

- op : pad2d
backward : pad2d_grad
extra :
Expand Down
8 changes: 8 additions & 0 deletions paddle/phi/api/yaml/op_version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
comment : In order to force fill output variable to gpu memory.
default : "false"

- op : p_norm
version :
- checkpoint : Upgrade p_norm, add 1 attribute [asvector].
action :
- add_attr : asvector
comment : Compute as vector when axis is None and input is matrix.
default : "false"

- op : pixel_shuffle
version :
- checkpoint : Compatible upgrade of pixel_shuffle, add a new attribute [data_format]
Expand Down
9 changes: 9 additions & 0 deletions paddle/phi/api/yaml/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,15 @@
data_type : x
backward: overlap_add_grad

- op : p_norm
args : (Tensor x, float porder=2, int axis=-1, float epsilon=1.0e-12f, bool keepdim=false, bool asvector=false)
output : Tensor(out)
infer_meta :
func : PNormInferMeta
kernel :
func : p_norm
backward : p_norm_grad

- op : pixel_shuffle
args : (Tensor x, int upscale_factor=1, str data_format="NCHW")
output : Tensor
Expand Down
26 changes: 0 additions & 26 deletions paddle/phi/ops/compat/p_norm_sig.cc

This file was deleted.

0 comments on commit 2b98993

Please sign in to comment.