Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[static op generation] tile #53317

Closed
wants to merge 10 commits into from
Closed
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
238 changes: 0 additions & 238 deletions paddle/fluid/operators/tile_op.cc

This file was deleted.

19 changes: 19 additions & 0 deletions paddle/phi/api/yaml/backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,25 @@
func : thresholded_relu_grad
inplace : (out_grad -> x_grad)

- backward_op : tile_double_grad
forward : tile_grad (Tensor x, Tensor grad_out, IntArray repeat_times) -> Tensor(grad_x)
args : (Tensor grad_x_grad, IntArray repeat_times)
output : Tensor(grad_out_grad)
invoke : tile(grad_x_grad, repeat_times)

- backward_op : tile_grad
forward : tile (Tensor x, IntArray repeat_times) -> Tensor(out)
args : (Tensor x, Tensor out_grad, IntArray repeat_times)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : tile_grad
no_need_buffer : x
composite : tile_grad(x, out_grad, repeat_times, x_grad)
backward : tile_double_grad

- backward_op : topk_grad
forward : topk (Tensor x, Scalar k, int axis = -1, bool largest = true, bool sorted = true) -> Tensor(out), Tensor(indices)
args : (Tensor x, Tensor indices, Tensor out_grad, Scalar k, int axis, bool largest, bool sorted)
Expand Down
19 changes: 0 additions & 19 deletions paddle/phi/api/yaml/legacy_backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1014,25 +1014,6 @@
data_type : out_grad
optional : reserve_space

- backward_op : tile_double_grad
forward : tile_grad (Tensor x, Tensor grad_out, IntArray repeat_times) -> Tensor(grad_x)
args : (Tensor grad_x_grad, IntArray repeat_times)
output : Tensor(grad_out_grad)
invoke : tile(grad_x_grad, repeat_times)

- backward_op : tile_grad
forward : tile (Tensor x, IntArray repeat_times) -> Tensor(out)
args : (Tensor x, Tensor out_grad, IntArray repeat_times)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : tile_grad
no_need_buffer : x
composite : tile_grad(x, outgrad, repeat_times, x_grad)
backward : tile_double_grad

- backward_op : transpose_double_grad
forward : transpose_grad (Tensor grad_out, int[] perm) -> Tensor(grad_x)
args : (Tensor grad_x_grad, int[] perm)
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 @@ -1157,15 +1157,6 @@
backward : sync_batch_norm_grad
inplace : (mean -> mean_out), (variance -> variance_out)

- op : tile
args : (Tensor x, IntArray repeat_times = {})
output : Tensor(out)
infer_meta :
func : TileInferMeta
kernel :
func : tile
backward : tile_grad

- op : transpose
args : (Tensor x, int[] perm)
output : Tensor
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,7 @@
data_type : int
tensor_name : RepeatTimes
tensors_name : repeat_times_tensor
manual_signature : [tile, tile_grad]

- op : topk (top_k_v2)
backward : topk_grad (top_k_v2_grad)
Expand Down
10 changes: 10 additions & 0 deletions paddle/phi/api/yaml/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,16 @@
func : thresholded_relu
backward : thresholded_relu_grad

- op : tile
args : (Tensor x, IntArray repeat_times = {})
output : Tensor(out)
infer_meta :
func : TileInferMeta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

op_compat.yaml中增加

manual_signature : [tile]

表示tile的signature保持手写,但是tle_grad和tile_double_grad不需要保持手写,所以需要删除paddle/phi/ops/compat/tile_sig.cc中grad的相关代码,保留tile的代码

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该写 manual_signature : [tile, tile_grad]吧, tle_grad 也需要保持手写

KernelSignature TileGradOpArgumentMapping(const ArgumentMappingContext& ctx) {

kernel :
func : tile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

增加data_type : x

data_type : x
backward : tile_grad

- op : topk
args : (Tensor x, Scalar(int) k = 1, int axis = -1, bool largest = true, bool sorted = true)
output : Tensor(out), Tensor(indices)
Expand Down