Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a3cd9cb9
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
a3cd9cb9
编写于
4月 23, 2023
作者:
Z
zhangyuqin1998
提交者:
GitHub
4月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete axis from elementwise_grad (#53202)
* remove axis from elementwise_grad * Update elementwise_sig.cc
上级
e123b98e
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
16 addition
and
40 deletion
+16
-40
paddle/fluid/operators/elementwise/elementwise_max_op.cc
paddle/fluid/operators/elementwise/elementwise_max_op.cc
+1
-8
paddle/fluid/operators/elementwise/elementwise_pow_op.cc
paddle/fluid/operators/elementwise/elementwise_pow_op.cc
+1
-8
paddle/fluid/prim/api/composite_backward/composite_backward_api.h
...luid/prim/api/composite_backward/composite_backward_api.h
+0
-2
paddle/phi/api/yaml/legacy_backward.yaml
paddle/phi/api/yaml/legacy_backward.yaml
+3
-3
paddle/phi/kernels/cpu/elementwise_grad_kernel.cc
paddle/phi/kernels/cpu/elementwise_grad_kernel.cc
+2
-2
paddle/phi/kernels/elementwise_grad_kernel.h
paddle/phi/kernels/elementwise_grad_kernel.h
+0
-3
paddle/phi/kernels/gpu/elementwise_grad_kernel.cu
paddle/phi/kernels/gpu/elementwise_grad_kernel.cu
+2
-3
paddle/phi/kernels/impl/elementwise_grad_kernel_impl.h
paddle/phi/kernels/impl/elementwise_grad_kernel_impl.h
+1
-1
paddle/phi/kernels/xpu/elementwise_grad_kernel.cc
paddle/phi/kernels/xpu/elementwise_grad_kernel.cc
+2
-4
paddle/phi/ops/compat/elementwise_sig.cc
paddle/phi/ops/compat/elementwise_sig.cc
+4
-6
未找到文件。
paddle/fluid/operators/elementwise/elementwise_max_op.cc
浏览文件 @
a3cd9cb9
...
...
@@ -86,15 +86,8 @@ class ElementwiseMaxCompositeGradOpMaker
paddle
::
Tensor
dy
=
this
->
GetSingleInputGrad
(
"Y"
);
auto
*
dy_ptr
=
this
->
GetOutputPtr
(
&
dy
);
std
::
string
dy_name
=
this
->
GetOutputName
(
dy
);
int
axis
=
static_cast
<
int
>
(
this
->
Attr
<
int
>
(
"axis"
));
PADDLE_ENFORCE_EQ
(
axis
,
-
1
,
phi
::
errors
::
InvalidArgument
(
"We only support axis = -1 in composite maximum_grad but we got: "
,
axis
));
VLOG
(
6
)
<<
"Runing maximum_grad composite func"
;
prim
::
maximum_grad
<
prim
::
DescTensor
>
(
x
,
y
,
out_grad
,
axis
,
dx_ptr
,
dy_ptr
);
prim
::
maximum_grad
<
prim
::
DescTensor
>
(
x
,
y
,
out_grad
,
dx_ptr
,
dy_ptr
);
this
->
RecoverOutputName
(
dx
,
dx_name
);
this
->
RecoverOutputName
(
dy
,
dy_name
);
}
...
...
paddle/fluid/operators/elementwise/elementwise_pow_op.cc
浏览文件 @
a3cd9cb9
...
...
@@ -60,15 +60,8 @@ class ElementwisePowCompositeGradOpMaker
paddle
::
Tensor
dy
=
this
->
GetSingleInputGrad
(
"Y"
);
auto
dy_ptr
=
this
->
GetOutputPtr
(
&
dy
);
std
::
string
dy_name
=
this
->
GetOutputName
(
dy
);
int
axis
=
static_cast
<
int
>
(
this
->
Attr
<
int
>
(
"axis"
));
PADDLE_ENFORCE_EQ
(
axis
,
-
1
,
phi
::
errors
::
InvalidArgument
(
"We only support axis = -1 in composite pow but we got: "
,
axis
));
VLOG
(
6
)
<<
"Runing pow_grad composite func"
;
prim
::
elementwise_pow_grad
<
prim
::
DescTensor
>
(
x
,
y
,
out_grad
,
axis
,
dx_ptr
,
dy_ptr
);
x
,
y
,
out_grad
,
dx_ptr
,
dy_ptr
);
this
->
RecoverOutputName
(
dx
,
dx_name
);
this
->
RecoverOutputName
(
dy
,
dy_name
);
}
...
...
paddle/fluid/prim/api/composite_backward/composite_backward_api.h
浏览文件 @
a3cd9cb9
...
...
@@ -391,7 +391,6 @@ template <typename T>
void
elementwise_pow_grad
(
const
Tensor
&
x
,
const
Tensor
&
y
,
const
Tensor
&
out_grad
,
int
axis
,
Tensor
*
dx
,
Tensor
*
dy
)
{
if
(
dy
)
{
...
...
@@ -1380,7 +1379,6 @@ template <typename T>
void
maximum_grad
(
const
Tensor
&
x
,
const
Tensor
&
y
,
const
Tensor
&
out_grad
,
int
axis
,
Tensor
*
x_grad
,
Tensor
*
y_grad
)
{
if
(
x_grad
)
{
...
...
paddle/phi/api/yaml/legacy_backward.yaml
浏览文件 @
a3cd9cb9
...
...
@@ -332,7 +332,7 @@
-
backward_op
:
elementwise_pow_grad
forward
:
elementwise_pow(Tensor x, Tensor y) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor out_grad
, int axis=-1
)
args
:
(Tensor x, Tensor y, Tensor out_grad)
output
:
Tensor(x_grad), Tensor(y_grad)
infer_meta
:
func
:
GeneralBinaryGradInferMeta
...
...
@@ -577,7 +577,7 @@
-
backward_op
:
maximum_grad
forward
:
maximum(Tensor x, Tensor y) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor out_grad
, int axis=-1
)
args
:
(Tensor x, Tensor y, Tensor out_grad)
output
:
Tensor(x_grad), Tensor(y_grad)
infer_meta
:
func
:
GeneralBinaryGradInferMeta
...
...
@@ -616,7 +616,7 @@
-
backward_op
:
minimum_grad
forward
:
minimum(Tensor x, Tensor y) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor out_grad
, int axis=-1
)
args
:
(Tensor x, Tensor y, Tensor out_grad)
output
:
Tensor(x_grad), Tensor(y_grad)
infer_meta
:
func
:
GeneralBinaryGradInferMeta
...
...
paddle/phi/kernels/cpu/elementwise_grad_kernel.cc
浏览文件 @
a3cd9cb9
...
...
@@ -28,10 +28,10 @@ void MaximumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
funcs
::
ElementwiseGradPreProcess
(
dout
,
dx
);
int
axis
=
-
1
;
phi
::
funcs
::
ElemwiseGradCompute
<
Context
,
T
,
MaxGradDx
<
T
>
,
MaxGradDy
<
T
>>
(
dev_ctx
,
x
,
y
,
dout
,
dout
,
axis
,
dx
,
dy
,
MaxGradDx
<
T
>
(),
MaxGradDy
<
T
>
());
}
...
...
@@ -41,10 +41,10 @@ void MinimumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
funcs
::
ElementwiseGradPreProcess
(
dout
,
dx
);
int
axis
=
-
1
;
phi
::
funcs
::
ElemwiseGradCompute
<
Context
,
T
,
MinGradDx
<
T
>
,
MinGradDy
<
T
>>
(
dev_ctx
,
x
,
y
,
dout
,
dout
,
axis
,
dx
,
dy
,
MinGradDx
<
T
>
(),
MinGradDy
<
T
>
());
}
...
...
paddle/phi/kernels/elementwise_grad_kernel.h
浏览文件 @
a3cd9cb9
...
...
@@ -40,7 +40,6 @@ void MaximumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
);
...
...
@@ -49,7 +48,6 @@ void MinimumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
);
...
...
@@ -66,7 +64,6 @@ void ElementwisePowGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
);
}
// namespace phi
paddle/phi/kernels/gpu/elementwise_grad_kernel.cu
浏览文件 @
a3cd9cb9
...
...
@@ -31,11 +31,10 @@ void MaximumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
const
auto
place
=
dev_ctx
.
GetPlace
();
int
axis
=
-
1
;
if
(
dx
!=
nullptr
&&
dy
!=
nullptr
)
{
std
::
vector
<
const
DenseTensor
*>
ins
=
{
&
x
,
&
y
,
&
dout
};
GetGradXAndYOut
<
ElementwiseType
::
kTernary
,
T
>
(
...
...
@@ -63,10 +62,10 @@ void MinimumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
const
auto
place
=
dev_ctx
.
GetPlace
();
int
axis
=
-
1
;
if
(
dx
!=
nullptr
&&
dy
!=
nullptr
)
{
std
::
vector
<
const
DenseTensor
*>
ins
=
{
&
x
,
&
y
,
&
dout
};
GetGradXAndYOut
<
ElementwiseType
::
kTernary
,
T
>
(
...
...
paddle/phi/kernels/impl/elementwise_grad_kernel_impl.h
浏览文件 @
a3cd9cb9
...
...
@@ -958,10 +958,10 @@ void ElementwisePowGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
funcs
::
ElementwiseGradPreProcess
(
dout
,
dx
);
int
axis
=
-
1
;
phi
::
funcs
::
ElemwiseGradCompute
<
Context
,
T
,
PowGradDX
<
T
>
,
PowGradDY
<
T
>>
(
dev_ctx
,
x
,
y
,
dout
,
dout
,
axis
,
dx
,
dy
,
PowGradDX
<
T
>
(),
PowGradDY
<
T
>
());
}
...
...
paddle/phi/kernels/xpu/elementwise_grad_kernel.cc
浏览文件 @
a3cd9cb9
...
...
@@ -25,11 +25,10 @@ void MaximumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
int
axis
=
-
1
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
...
...
@@ -51,11 +50,10 @@ void MinimumGradKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
const
DenseTensor
&
dout
,
int
axis
,
DenseTensor
*
dx
,
DenseTensor
*
dy
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
int
axis
=
-
1
;
auto
f
=
[](
xpu
::
Context
*
ctx
,
const
XPUType
*
x
,
const
XPUType
*
y
,
...
...
paddle/phi/ops/compat/elementwise_sig.cc
浏览文件 @
a3cd9cb9
...
...
@@ -210,13 +210,13 @@ KernelSignature ElementwiseMulTripleGradOpArgumentMapping(
KernelSignature
ElementwiseMaxGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"maximum_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{
"axis"
},
{
"X@GRAD"
,
"Y@GRAD"
});
"maximum_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{},
{
"X@GRAD"
,
"Y@GRAD"
});
}
KernelSignature
ElementwiseMinGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"minimum_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{
"axis"
},
{
"X@GRAD"
,
"Y@GRAD"
});
"minimum_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{},
{
"X@GRAD"
,
"Y@GRAD"
});
}
KernelSignature
ElementwiseHeavisideGradOpArgumentMapping
(
...
...
@@ -227,10 +227,8 @@ KernelSignature ElementwiseHeavisideGradOpArgumentMapping(
KernelSignature
ElementwisePowGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"elementwise_pow_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{
"axis"
},
{
"X@GRAD"
,
"Y@GRAD"
});
return
KernelSignature
(
"elementwise_pow_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{},
{
"X@GRAD"
,
"Y@GRAD"
});
}
}
// namespace phi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录