Skip to content

Commit

Permalink
add autogen code support for affine_grid op (#52560)
Browse files Browse the repository at this point in the history
* add autogen code support for affine_grid op

* update op_compat.yaml for affine_grid

* update op_compat.yaml for affine_grid

* fix AffineGridGradInferMeta

* fix CI error

* update AffineGridInferMeta
  • Loading branch information
GreatV authored Apr 10, 2023
1 parent ec008a7 commit 9028054
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 386 deletions.
288 changes: 0 additions & 288 deletions paddle/fluid/operators/affine_grid_op.cc

This file was deleted.

11 changes: 11 additions & 0 deletions paddle/phi/api/yaml/backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
kernel :
func : addmm_grad

- backward_op : affine_grid_grad
forward : affine_grid (Tensor input, IntArray output_shape={}, bool align_corners=true) -> Tensor(output)
args : (Tensor input, Tensor output_grad, IntArray output_shape, bool align_corners=true)
output : Tensor(input_grad)
infer_meta :
func : AffineGridGradInferMeta
param : [output_grad, output_shape, align_corners]
kernel :
func : affine_grid_grad
param : [output_grad, output_shape, align_corners]

- backward_op : angle_grad
forward : angle (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out_grad)
Expand Down
12 changes: 0 additions & 12 deletions paddle/phi/api/yaml/legacy_backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,6 @@
func : add_triple_grad
inplace : (grad_grad_out_grad -> grad_grad_x_grad)

- backward_op : affine_grid_grad
forward : affine_grid (Tensor input, IntArray outputShape, bool align_corners=true) -> Tensor(output)
args : (Tensor input, Tensor output_grad, IntArray outputShape, bool align_corners=true)
output : Tensor(input_grad)
infer_meta :
func : AffineGridGradInferMeta
param : [output_grad, outputShape, align_corners]
kernel :
func : affine_grid_grad
param : [output_grad, outputShape, align_corners]
no_need_buffer : input

- backward_op : amax_grad
forward: amax (Tensor x, int64_t[] axis={}, bool keepdim=false) -> Tensor(out)
args : (Tensor x, Tensor out, Tensor out_grad, int64_t[] axis={}, bool keepdim=false, bool reduce_all=false)
Expand Down
12 changes: 0 additions & 12 deletions paddle/phi/api/yaml/legacy_ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,6 @@
invoke : add_n_impl(inputs)
backward : add_n_grad

- op : affine_grid
args : (Tensor input, IntArray outputShape, bool align_corners=true)
output : Tensor
infer_meta :
func : AffineGridInferMeta
param : [input, outputShape, align_corners]
kernel :
func : affine_grid
param : [input, outputShape, align_corners]
data_type : input
backward : affine_grid_grad

- op : all
args : (Tensor x, int64_t[] axis={}, bool keepdim=false)
output : Tensor(out)
Expand Down
8 changes: 8 additions & 0 deletions paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@

- op : affine_grid
backward : affine_grid_grad
inputs :
input : Theta
outputs :
out : Output
int_array:
output_shape :
data_type : int
tensor_name : OutputShape
extra :
attrs : [bool use_cudnn = true]

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
@@ -1,3 +1,11 @@
- op : affine_grid
version :
- checkpoint : Compatible upgrade of affine_grid, add a new attribute [align_corners].
action :
- add_attr : align_corners
comment : Whether to align the corners of input and output.
default : "true"

- op : allclose
version :
- checkpoint : Upgrade allclose, add two new inputs [Rtol] and [Atol].
Expand Down
12 changes: 12 additions & 0 deletions paddle/phi/api/yaml/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
data_type : x
backward : addmm_grad

- op : affine_grid
args : (Tensor input, IntArray output_shape={}, bool align_corners=true)
output : Tensor
infer_meta :
func : AffineGridInferMeta
param : [input, output_shape, align_corners]
kernel :
func : affine_grid
param : [input, output_shape, align_corners]
data_type : input
backward : affine_grid_grad

- op : allclose
args : (Tensor x, Tensor y, Scalar rtol="1e-5", Scalar atol="1e-8", bool equal_nan=false)
output : Tensor(out)
Expand Down
Loading

0 comments on commit 9028054

Please sign in to comment.