Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
f196b84e
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f196b84e
编写于
4月 08, 2022
作者:
Y
YuanRisheng
提交者:
GitHub
4月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs of reshape double grad infermeta (#41459) (#41493)
上级
57fe4fc9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
20 addition
and
5 deletion
+20
-5
paddle/fluid/operators/reshape_op.cc
paddle/fluid/operators/reshape_op.cc
+5
-4
paddle/phi/infermeta/backward.cc
paddle/phi/infermeta/backward.cc
+8
-0
paddle/phi/infermeta/backward.h
paddle/phi/infermeta/backward.h
+4
-0
paddle/phi/kernels/reshape_grad_kernel.cc
paddle/phi/kernels/reshape_grad_kernel.cc
+1
-0
paddle/phi/kernels/reshape_grad_kernel.h
paddle/phi/kernels/reshape_grad_kernel.h
+1
-0
paddle/phi/ops/compat/reshape_sig.cc
paddle/phi/ops/compat/reshape_sig.cc
+1
-1
未找到文件。
paddle/fluid/operators/reshape_op.cc
浏览文件 @
f196b84e
...
...
@@ -441,26 +441,27 @@ class ReshapeDoubleGradKernel {
public:
void
operator
()(
const
framework
::
ExecutionContext
&
ctx
)
const
{
auto
*
dd_x
=
ctx
.
Input
<
framework
::
Tensor
>
(
"DDX"
);
auto
*
d_out
=
ctx
.
Input
<
framework
::
Tensor
>
(
"DOut"
);
auto
*
dd_out
=
ctx
.
Output
<
framework
::
Tensor
>
(
"DDOut"
);
dd_out
->
mutable_data
(
ctx
.
GetPlace
(),
dd_x
->
type
());
if
(
platform
::
is_cpu_place
(
ctx
.
GetPlace
()))
{
auto
&
dev_ctx
=
ctx
.
device_context
<
platform
::
CPUDeviceContext
>
();
phi
::
ReshapeDoubleGradKernel
(
static_cast
<
const
phi
::
CPUContext
&>
(
dev_ctx
),
*
dd_x
,
dd_out
);
static_cast
<
const
phi
::
CPUContext
&>
(
dev_ctx
),
*
d
_out
,
*
d
d_x
,
dd_out
);
}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
if
(
platform
::
is_gpu_place
(
ctx
.
GetPlace
()))
{
auto
&
dev_ctx
=
ctx
.
device_context
<
platform
::
CUDADeviceContext
>
();
phi
::
ReshapeDoubleGradKernel
(
static_cast
<
const
phi
::
GPUContext
&>
(
dev_ctx
),
*
dd_x
,
dd_out
);
static_cast
<
const
phi
::
GPUContext
&>
(
dev_ctx
),
*
d
_out
,
*
d
d_x
,
dd_out
);
}
#endif
#ifdef PADDLE_WITH_XPU
if
(
platform
::
is_xpu_place
(
ctx
.
GetPlace
()))
{
auto
&
dev_ctx
=
ctx
.
device_context
<
platform
::
XPUDeviceContext
>
();
phi
::
ReshapeDoubleGradKernel
(
static_cast
<
const
phi
::
XPUContext
&>
(
dev_ctx
),
*
dd_x
,
dd_out
);
static_cast
<
const
phi
::
XPUContext
&>
(
dev_ctx
),
*
d
_out
,
*
d
d_x
,
dd_out
);
}
#endif
}
...
...
@@ -658,7 +659,7 @@ REGISTER_OPERATOR(reshape2_grad, ops::Reshape2GradOp,
DECLARE_INFER_SHAPE_FUNCTOR
(
reshape2_grad_grad
,
Reshape2DoubleGradInferShapeFunctor
,
PD_INFER_META
(
phi
::
GeneralUnary
GradInferMeta
));
PD_INFER_META
(
phi
::
ReshapeDouble
GradInferMeta
));
REGISTER_OPERATOR
(
reshape2_grad_grad
,
ops
::
Reshape2DoubleGradOp
,
ops
::
ReshapeDoubleGradInplaceInferer
,
...
...
paddle/phi/infermeta/backward.cc
浏览文件 @
f196b84e
...
...
@@ -409,6 +409,14 @@ void RealAndImagGradInferMeta(const MetaTensor& out_grad, MetaTensor* dx) {
dx
->
set_layout
(
out_grad
.
layout
());
}
void
ReshapeDoubleGradInferMeta
(
const
MetaTensor
&
out_grad
,
const
MetaTensor
&
x_grad_grad
,
MetaTensor
*
out_grad_grad
)
{
if
(
out_grad_grad
!=
nullptr
)
{
out_grad_grad
->
share_dims
(
out_grad
);
}
}
void
ScatterGradInferMeta
(
const
MetaTensor
&
index
,
const
MetaTensor
&
updates
,
const
MetaTensor
&
out_grad
,
...
...
paddle/phi/infermeta/backward.h
浏览文件 @
f196b84e
...
...
@@ -176,6 +176,10 @@ void PoolGradInferMeta(const MetaTensor& x,
void
RealAndImagGradInferMeta
(
const
MetaTensor
&
out_grad
,
MetaTensor
*
dx
);
void
ReshapeDoubleGradInferMeta
(
const
MetaTensor
&
out_grad
,
const
MetaTensor
&
x_grad_grad
,
MetaTensor
*
out_grad_grad
);
void
ScatterGradInferMeta
(
const
MetaTensor
&
index
,
const
MetaTensor
&
updates
,
const
MetaTensor
&
out_grad
,
...
...
paddle/phi/kernels/reshape_grad_kernel.cc
浏览文件 @
f196b84e
...
...
@@ -30,6 +30,7 @@ void ReshapeGradKernel(const Context& dev_ctx,
template
<
typename
Context
>
void
ReshapeDoubleGradKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
out_grad
,
const
DenseTensor
&
x_grad_grad
,
DenseTensor
*
out_grad_grad
)
{
ReshapeGradKernel
(
dev_ctx
,
x_grad_grad
,
out_grad_grad
);
...
...
paddle/phi/kernels/reshape_grad_kernel.h
浏览文件 @
f196b84e
...
...
@@ -25,6 +25,7 @@ void ReshapeGradKernel(const Context& dev_ctx,
template
<
typename
Context
>
void
ReshapeDoubleGradKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
out_grad
,
const
DenseTensor
&
x_grad_grad
,
DenseTensor
*
out_grad_grad
);
...
...
paddle/phi/ops/compat/reshape_sig.cc
浏览文件 @
f196b84e
...
...
@@ -47,7 +47,7 @@ KernelSignature ReshapeGradOpArgumentMapping(
KernelSignature
ReshapeDoubleGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"reshape_double_grad"
,
{
"DDX"
},
{},
{
"DDOut"
});
return
KernelSignature
(
"reshape_double_grad"
,
{
"D
Out"
,
"D
DX"
},
{},
{
"DDOut"
});
}
}
// namespace phi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录