Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6198ff24
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6198ff24
编写于
7月 26, 2022
作者:
W
wanghuancoder
提交者:
GitHub
7月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add reverse yaml (#44518)
* add reverse yaml
上级
e0dd7f32
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
2 deletion
+66
-2
paddle/phi/api/yaml/legacy_api.yaml
paddle/phi/api/yaml/legacy_api.yaml
+18
-0
paddle/phi/api/yaml/legacy_backward.yaml
paddle/phi/api/yaml/legacy_backward.yaml
+17
-0
paddle/phi/infermeta/unary.cc
paddle/phi/infermeta/unary.cc
+19
-0
paddle/phi/infermeta/unary.h
paddle/phi/infermeta/unary.h
+4
-0
python/paddle/fluid/layers/tensor.py
python/paddle/fluid/layers/tensor.py
+5
-0
python/paddle/fluid/tests/unittests/test_reverse_op.py
python/paddle/fluid/tests/unittests/test_reverse_op.py
+3
-2
未找到文件。
paddle/phi/api/yaml/legacy_api.yaml
浏览文件 @
6198ff24
...
@@ -1802,6 +1802,24 @@
...
@@ -1802,6 +1802,24 @@
intermediate
:
xshape
intermediate
:
xshape
backward
:
reshape_grad
backward
:
reshape_grad
-
api
:
reverse
args
:
(Tensor x, int[] axis)
output
:
Tensor
infer_meta
:
func
:
ReverseInferMeta
kernel
:
func
:
reverse
backward
:
reverse_grad
-
api
:
reverse_array
args
:
(Tensor[] x, int[] axis)
output
:
Tensor[]{x.size()}
infer_meta
:
func
:
ReverseArrayInferMeta
kernel
:
func
:
reverse_array
backward
:
reverse_array_grad
-
api
:
roi_align
-
api
:
roi_align
args
:
(Tensor x, Tensor boxes, Tensor boxes_num, int pooled_height, int pooled_width, float spatial_scale, int sampling_ratio, bool aligned)
args
:
(Tensor x, Tensor boxes, Tensor boxes_num, int pooled_height, int pooled_width, float spatial_scale, int sampling_ratio, bool aligned)
output
:
Tensor
output
:
Tensor
...
...
paddle/phi/api/yaml/legacy_backward.yaml
浏览文件 @
6198ff24
...
@@ -1708,6 +1708,23 @@
...
@@ -1708,6 +1708,23 @@
backward
:
reshape_double_grad
backward
:
reshape_double_grad
inplace
:
(out_grad -> x_grad)
inplace
:
(out_grad -> x_grad)
-
backward_api
:
reverse_array_grad
forward
:
reverse_array (Tensor[] x, int[] axis) -> Tensor[](out)
args
:
(Tensor[] out_grad, int[] axis)
output
:
Tensor[](x_grad){out_grad.size()}
infer_meta
:
func
:
ReverseArrayInferMeta
kernel
:
func
:
reverse
-
backward_api
:
reverse_grad
forward
:
reverse (Tensor x, int[] axis) -> Tensor(out)
args
:
(Tensor out_grad, int[] axis)
output
:
Tensor(x_grad)
infer_meta
:
func
:
ReverseInferMeta
invoke
:
reverse(out_grad, axis)
-
backward_api
:
roi_align_grad
-
backward_api
:
roi_align_grad
forward
:
roi_align (Tensor x, Tensor boxes, Tensor boxes_num, int pooled_height, int pooled_width, float spatial_scale, int sampling_ratio, bool aligned) -> Tensor(out)
forward
:
roi_align (Tensor x, Tensor boxes, Tensor boxes_num, int pooled_height, int pooled_width, float spatial_scale, int sampling_ratio, bool aligned) -> Tensor(out)
args
:
(Tensor x, Tensor boxes, Tensor boxes_num, Tensor out_grad, int pooled_height, int pooled_width, float spatial_scale, int sampling_ratio, bool aligned)
args
:
(Tensor x, Tensor boxes, Tensor boxes_num, Tensor out_grad, int pooled_height, int pooled_width, float spatial_scale, int sampling_ratio, bool aligned)
...
...
paddle/phi/infermeta/unary.cc
浏览文件 @
6198ff24
...
@@ -2165,6 +2165,25 @@ void ReverseInferMeta(const MetaTensor& x,
...
@@ -2165,6 +2165,25 @@ void ReverseInferMeta(const MetaTensor& x,
out
->
share_meta
(
x
);
out
->
share_meta
(
x
);
}
}
void
ReverseArrayInferMeta
(
const
std
::
vector
<
const
phi
::
MetaTensor
*>&
x
,
const
std
::
vector
<
int
>&
axis
,
std
::
vector
<
phi
::
MetaTensor
*>
out
)
{
PADDLE_ENFORCE_EQ
(
axis
.
size
(),
1
,
phi
::
errors
::
InvalidArgument
(
"The size of axis must be 1 when the Input(X) is LoDTensorArray, "
"but received %d."
,
axis
.
size
()));
PADDLE_ENFORCE_EQ
(
axis
[
0
],
0
,
phi
::
errors
::
InvalidArgument
(
"The value of axis should be 1 when "
"the Input(X) is LoDTensorArray, "
"but received %d."
,
axis
[
0
]));
}
void
RollInferMeta
(
const
MetaTensor
&
x
,
void
RollInferMeta
(
const
MetaTensor
&
x
,
const
IntArray
&
shifts
,
const
IntArray
&
shifts
,
const
std
::
vector
<
int64_t
>&
axis
,
const
std
::
vector
<
int64_t
>&
axis
,
...
...
paddle/phi/infermeta/unary.h
浏览文件 @
6198ff24
...
@@ -298,6 +298,10 @@ void ReverseInferMeta(const MetaTensor& x,
...
@@ -298,6 +298,10 @@ void ReverseInferMeta(const MetaTensor& x,
const
std
::
vector
<
int
>&
axis
,
const
std
::
vector
<
int
>&
axis
,
MetaTensor
*
out
);
MetaTensor
*
out
);
void
ReverseArrayInferMeta
(
const
std
::
vector
<
const
phi
::
MetaTensor
*>&
x
,
const
std
::
vector
<
int
>&
axis
,
std
::
vector
<
phi
::
MetaTensor
*>
out
);
void
RollInferMeta
(
const
MetaTensor
&
x
,
void
RollInferMeta
(
const
MetaTensor
&
x
,
const
IntArray
&
shifts
,
const
IntArray
&
shifts
,
const
std
::
vector
<
int64_t
>&
axis
,
const
std
::
vector
<
int64_t
>&
axis
,
...
...
python/paddle/fluid/layers/tensor.py
浏览文件 @
6198ff24
...
@@ -1271,6 +1271,11 @@ def reverse(x, axis):
...
@@ -1271,6 +1271,11 @@ def reverse(x, axis):
check_type
(
axis
,
'axis'
,
(
int
,
tuple
,
list
),
'reverse'
)
check_type
(
axis
,
'axis'
,
(
int
,
tuple
,
list
),
'reverse'
)
if
isinstance
(
axis
,
int
):
if
isinstance
(
axis
,
int
):
axis
=
[
axis
]
axis
=
[
axis
]
if
in_dygraph_mode
():
if
x
.
type
==
core
.
VarDesc
.
VarType
.
LOD_TENSOR_ARRAY
:
return
_C_ops
.
final_state_reverse_array
(
x
,
axis
)
else
:
return
_C_ops
.
final_state_reverse
(
x
,
axis
)
helper
=
LayerHelper
(
"reverse"
,
**
locals
())
helper
=
LayerHelper
(
"reverse"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
helper
.
append_op
(
type
=
'reverse'
,
helper
.
append_op
(
type
=
'reverse'
,
...
...
python/paddle/fluid/tests/unittests/test_reverse_op.py
浏览文件 @
6198ff24
...
@@ -31,6 +31,7 @@ class TestReverseOp(OpTest):
...
@@ -31,6 +31,7 @@ class TestReverseOp(OpTest):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
initTestCase
()
self
.
op_type
=
"reverse"
self
.
op_type
=
"reverse"
self
.
python_api
=
fluid
.
layers
.
reverse
self
.
inputs
=
{
"X"
:
self
.
x
}
self
.
inputs
=
{
"X"
:
self
.
x
}
self
.
attrs
=
{
'axis'
:
self
.
axis
}
self
.
attrs
=
{
'axis'
:
self
.
axis
}
out
=
self
.
x
out
=
self
.
x
...
@@ -39,10 +40,10 @@ class TestReverseOp(OpTest):
...
@@ -39,10 +40,10 @@ class TestReverseOp(OpTest):
self
.
outputs
=
{
'Out'
:
out
}
self
.
outputs
=
{
'Out'
:
out
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
()
self
.
check_output
(
check_eager
=
True
)
def
test_check_grad
(
self
):
def
test_check_grad
(
self
):
self
.
check_grad
([
'X'
],
'Out'
)
self
.
check_grad
([
'X'
],
'Out'
,
check_eager
=
True
)
class
TestCase0
(
TestReverseOp
):
class
TestCase0
(
TestReverseOp
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录