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 graph autogen code for expand #54628

Merged
merged 9 commits into from
Jun 30, 2023
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
9 changes: 0 additions & 9 deletions paddle/fluid/operators/expand_op.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -128,23 +125,17 @@ Expand operator tiles the input by given times number. You should set times
number for each dimension by providing attribute 'expand_times'. The rank of X
should be in [1, 6]. Please note that size of 'expand_times' must be the same
with X's rank. Following is a using case:

Input(X) is a 3-D tensor with shape [2, 3, 1]:

[
[[1], [2], [3]],
[[4], [5], [6]]
]

Attr(expand_times): [1, 2, 2]

Output(Out) is a 3-D tensor with shape [2, 6, 2]:

[
[[1, 1], [2, 2], [3, 3], [1, 1], [2, 2], [3, 3]],
[[4, 4], [5, 5], [6, 6], [4, 4], [5, 5], [6, 6]]
]

)DOC");
}
};
Expand Down
255 changes: 0 additions & 255 deletions paddle/fluid/operators/expand_v2_op.cc

This file was deleted.

20 changes: 20 additions & 0 deletions paddle/phi/api/yaml/backward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,26 @@
func : expand_as_grad
no_need_buffer : x

- backward_op : expand_double_grad
forward : expand_grad (Tensor x, Tensor grad_out, IntArray shape) -> Tensor(grad_x)
args : (Tensor grad_x_grad, IntArray shape)
output : Tensor(grad_out_grad)
invoke : expand(grad_x_grad, shape)

- backward_op : expand_grad
forward : expand (Tensor x, IntArray shape) -> Tensor(out)
args : (Tensor x, Tensor out_grad, IntArray shape)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : expand_grad
data_type : out_grad
no_need_buffer : x
backward : expand_double_grad
composite: expand_grad(x, out_grad, shape, x_grad)

- backward_op : expm1_grad
forward : expm1 (Tensor x) -> Tensor(out)
args : (Tensor out, Tensor out_grad)
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 @@ -255,25 +255,6 @@
invoke : embedding_grad_impl(x, weight, out_grad, padding_idx, sparse, weight_grad)
no_need_buffer : weight

- backward_op : expand_double_grad
forward : expand_grad (Tensor x, Tensor grad_out, IntArray shape) -> Tensor(grad_x)
args : (Tensor grad_x_grad, IntArray shape)
output : Tensor(grad_out_grad)
invoke : expand(grad_x_grad, shape)

- backward_op : expand_grad
forward : expand (Tensor x, IntArray shape) -> Tensor(out)
args : (Tensor x, Tensor out_grad, IntArray shape)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : expand_grad
no_need_buffer : x
backward : expand_double_grad
composite: expand_grad(x, out_grad, shape, x_grad)

- backward_op : exponential__grad
forward : exponential_ (Tensor x, float lam) -> Tensor(out)
args : (Tensor out_grad)
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 @@ -302,15 +302,6 @@
kernel :
func : equal

- op : expand
args : (Tensor x, IntArray shape)
output : Tensor
infer_meta :
func : ExpandInferMeta
kernel :
func : expand
backward : expand_grad

- op : exponential_
args : (Tensor x, float lam)
output : Tensor(out)
Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@
attrs : [bool use_mkldnn = false, bool use_cudnn = false]

- op : expand (expand_v2)
backward : expand_grad (expand_v2_grad)
backward : expand_grad (expand_v2_grad), expand_double_grad(expand_v2_double_grad)
inputs :
x : X
attrs :
Expand All @@ -928,6 +928,7 @@
tensors_name : expand_shapes_tensor
extra :
attrs : [bool use_mkldnn = false, str mkldnn_data_type = "float32"]
manual_signature : [expand, expand_grad]

- op : expand_as (expand_as_v2)
backward : expand_as_grad (expand_as_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 @@ -762,6 +762,16 @@
inplace : (x -> out)
backward : exp_grad

- op : expand
args : (Tensor x, IntArray shape = {})
output : Tensor(out)
infer_meta :
func : ExpandInferMeta
kernel :
func : expand
data_type : x
backward : expand_grad

- op : expand_as
args : (Tensor x, Tensor y, int[] target_shape = {})
output : Tensor(out)
Expand Down
Loading