Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3e636ec9
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看板
未验证
提交
3e636ec9
编写于
3月 15, 2023
作者:
Z
zhangyuqin1998
提交者:
GitHub
3月 15, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete hardswish_raw op (#51634)
* Delete hardswish_raw op * fix ut
上级
bcec0dce
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
45 addition
and
87 deletion
+45
-87
paddle/phi/api/yaml/legacy_backward.yaml
paddle/phi/api/yaml/legacy_backward.yaml
+1
-1
paddle/phi/kernels/activation_grad_kernel.h
paddle/phi/kernels/activation_grad_kernel.h
+0
-3
paddle/phi/kernels/activation_kernel.cc
paddle/phi/kernels/activation_kernel.cc
+0
-25
paddle/phi/kernels/activation_kernel.h
paddle/phi/kernels/activation_kernel.h
+0
-8
paddle/phi/kernels/cpu/activation_grad_kernel.cc
paddle/phi/kernels/cpu/activation_grad_kernel.cc
+3
-3
paddle/phi/kernels/cpu/activation_kernel.cc
paddle/phi/kernels/cpu/activation_kernel.cc
+7
-7
paddle/phi/kernels/gpu/activation_grad_kernel.cu
paddle/phi/kernels/gpu/activation_grad_kernel.cu
+3
-3
paddle/phi/kernels/gpu/activation_kernel.cu
paddle/phi/kernels/gpu/activation_kernel.cu
+7
-7
paddle/phi/kernels/onednn/activation_grad_kernel.cc
paddle/phi/kernels/onednn/activation_grad_kernel.cc
+0
-3
paddle/phi/kernels/onednn/activation_kernel.cc
paddle/phi/kernels/onednn/activation_kernel.cc
+5
-8
paddle/phi/kernels/xpu/activation_grad_kernel.cc
paddle/phi/kernels/xpu/activation_grad_kernel.cc
+3
-3
paddle/phi/kernels/xpu/activation_kernel.cc
paddle/phi/kernels/xpu/activation_kernel.cc
+7
-7
paddle/phi/ops/compat/activation_sig.cc
paddle/phi/ops/compat/activation_sig.cc
+6
-6
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_swish.py
...sts/unittests/ir/inference/test_trt_convert_hard_swish.py
+3
-3
未找到文件。
paddle/phi/api/yaml/legacy_backward.yaml
浏览文件 @
3e636ec9
...
...
@@ -532,7 +532,7 @@
-
backward_op
:
hardswish_grad
forward
:
hardswish (Tensor x) -> Tensor(out)
args
:
(Tensor x, Tensor out_grad
, float threshold = 6.0, float scale = 6.0, float offset = 3.0
)
args
:
(Tensor x, Tensor out_grad)
output
:
Tensor(x_grad)
infer_meta
:
func
:
UnchangedInferMeta
...
...
paddle/phi/kernels/activation_grad_kernel.h
浏览文件 @
3e636ec9
...
...
@@ -225,9 +225,6 @@ template <typename T, typename Context>
void
HardSwishGradKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
dout
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
dx
);
template
<
typename
T
,
typename
Context
>
...
...
paddle/phi/kernels/activation_kernel.cc
浏览文件 @
3e636ec9
...
...
@@ -19,13 +19,6 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
HardSwishKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
HardSwishRawKernel
<
T
,
Context
>
(
dev_ctx
,
x
,
6
,
6
,
3
,
out
);
}
template
<
typename
T
,
typename
Context
>
void
Relu6Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
@@ -44,21 +37,10 @@ void SwishKernel(const Context& dev_ctx,
using
complex64
=
::
phi
::
dtype
::
complex
<
float
>
;
using
complex128
=
::
phi
::
dtype
::
complex
<
double
>
;
PD_REGISTER_KERNEL
(
hardswish
,
CPU
,
ALL_LAYOUT
,
phi
::
HardSwishKernel
,
float
,
double
)
{}
PD_REGISTER_KERNEL
(
relu6
,
CPU
,
ALL_LAYOUT
,
phi
::
Relu6Kernel
,
float
,
double
)
{}
PD_REGISTER_KERNEL
(
swish
,
CPU
,
ALL_LAYOUT
,
phi
::
SwishKernel
,
float
,
double
)
{}
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_REGISTER_KERNEL
(
hardswish
,
GPU
,
ALL_LAYOUT
,
phi
::
HardSwishKernel
,
float
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{}
PD_REGISTER_KERNEL
(
relu6
,
GPU
,
ALL_LAYOUT
,
...
...
@@ -80,18 +62,11 @@ PD_REGISTER_KERNEL(swish,
#endif
#if defined PADDLE_WITH_XPU
PD_REGISTER_KERNEL
(
hardswish
,
XPU
,
ALL_LAYOUT
,
phi
::
HardSwishKernel
,
float
)
{}
PD_REGISTER_KERNEL
(
relu6
,
XPU
,
ALL_LAYOUT
,
phi
::
Relu6Kernel
,
float
)
{}
PD_REGISTER_KERNEL
(
swish
,
XPU
,
ALL_LAYOUT
,
phi
::
SwishKernel
,
float
)
{}
#endif
#ifdef PADDLE_WITH_MKLDNN
PD_REGISTER_KERNEL
(
hardswish
,
OneDNN
,
ONEDNN
,
phi
::
HardSwishKernel
,
float
,
phi
::
dtype
::
bfloat16
)
{}
PD_REGISTER_KERNEL
(
relu6
,
OneDNN
,
ONEDNN
,
phi
::
Relu6Kernel
,
float
,
phi
::
dtype
::
bfloat16
)
{}
PD_REGISTER_KERNEL
(
...
...
paddle/phi/kernels/activation_kernel.h
浏览文件 @
3e636ec9
...
...
@@ -90,14 +90,6 @@ DECLARE_ACTIVATION_KERNEL_WITH_TWO_ATTRS(STanh, scale_a, scale_b)
DECLARE_ACTIVATION_KERNEL_WITH_TWO_ATTRS
(
Softplus
,
beta
,
threshold
)
DECLARE_ACTIVATION_KERNEL_WITH_TWO_ATTRS
(
HardSigmoid
,
slope
,
offset
)
template
<
typename
T
,
typename
Context
>
void
HardSwishRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
void
HardSwishKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
paddle/phi/kernels/cpu/activation_grad_kernel.cc
浏览文件 @
3e636ec9
...
...
@@ -226,11 +226,11 @@ template <typename T, typename Context>
void
HardSwishGradKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
dout
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
dx
)
{
funcs
::
HardSwishGradFunctor
<
T
>
functor
;
float
threshold
=
6
;
float
scale
=
6
;
float
offset
=
3
;
auto
attrs
=
functor
.
GetAttrs
();
*
(
attrs
[
0
].
second
)
=
threshold
;
*
(
attrs
[
1
].
second
)
=
scale
;
...
...
paddle/phi/kernels/cpu/activation_kernel.cc
浏览文件 @
3e636ec9
...
...
@@ -113,13 +113,13 @@ DEFINE_CPU_ACT_KERNEL_WITH_TWO_ATTRS(HardSigmoid,
offset
)
template
<
typename
T
,
typename
Context
>
void
HardSwishRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
out
)
{
void
HardSwishKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
funcs
::
HardSwishFunctor
<
T
>
functor
;
float
threshold
=
6
;
float
scale
=
6
;
float
offset
=
3
;
auto
attrs
=
functor
.
GetAttrs
();
*
(
attrs
[
0
].
second
)
=
threshold
;
*
(
attrs
[
1
].
second
)
=
scale
;
...
...
@@ -183,7 +183,7 @@ PD_REGISTER_ACTIVATION_KERNEL(log2, Log2Kernel)
PD_REGISTER_ACTIVATION_KERNEL
(
log10
,
Log10Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
log1p
,
Log1pKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
swish_raw
,
SwishRawKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
_raw
,
HardSwishRaw
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
,
HardSwish
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
round
,
RoundKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
floor
,
FloorKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
ceil
,
CeilKernel
)
...
...
paddle/phi/kernels/gpu/activation_grad_kernel.cu
浏览文件 @
3e636ec9
...
...
@@ -274,11 +274,11 @@ template <typename T, typename Context>
void
HardSwishGradKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
dout
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
dx
)
{
funcs
::
CudaHardSwishGradFunctor
<
T
>
functor
;
float
threshold
=
6
;
float
scale
=
6
;
float
offset
=
3
;
auto
attrs
=
functor
.
GetAttrs
();
*
(
attrs
[
0
].
second
)
=
threshold
;
*
(
attrs
[
1
].
second
)
=
scale
;
...
...
paddle/phi/kernels/gpu/activation_kernel.cu
浏览文件 @
3e636ec9
...
...
@@ -138,13 +138,13 @@ DEFINE_GPU_ACT_KERNEL_WITH_TWO_ATTRS(HardSigmoid,
DEFINE_GPU_ACT_KERNEL_WITH_TWO_ATTRS
(
Selu
,
CudaSeluFunctor
,
scale
,
alpha
)
template
<
typename
T
,
typename
Context
>
void
HardSwishRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
out
)
{
void
HardSwishKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
funcs
::
CudaHardSwishFunctor
<
T
>
functor
;
float
threshold
=
6
;
float
scale
=
6
;
float
offset
=
3
;
auto
attrs
=
functor
.
GetAttrs
();
*
(
attrs
[
0
].
second
)
=
threshold
;
*
(
attrs
[
1
].
second
)
=
scale
;
...
...
@@ -257,7 +257,7 @@ PD_REGISTER_ACTIVATION_KERNEL(log, LogKernel)
PD_REGISTER_ACTIVATION_KERNEL
(
log2
,
Log2Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
log10
,
Log10Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
log1p
,
Log1pKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
_raw
,
HardSwishRaw
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
,
HardSwish
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
swish_raw
,
SwishRawKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
round
,
RoundKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
floor
,
FloorKernel
)
...
...
paddle/phi/kernels/onednn/activation_grad_kernel.cc
浏览文件 @
3e636ec9
...
...
@@ -238,9 +238,6 @@ template <typename T, typename Context>
void
HardSwishGradKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
dout
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
dx
)
{
HardSwishOneDNNGradFunctor
<
T
>
functor
;
functor
(
dev_ctx
,
x
,
dout
,
0
,
0
,
dx
);
...
...
paddle/phi/kernels/onednn/activation_kernel.cc
浏览文件 @
3e636ec9
...
...
@@ -157,14 +157,11 @@ DEFINE_ONEDNN_ACT_KERNEL_WITH_ONE_ATTRS(Mish, MishOneDNNFunctor, threshold)
DEFINE_ONEDNN_ACT_KERNEL_WITH_ONE_ATTRS
(
SwishRaw
,
SwishOneDNNFunctor
,
beta
)
template
<
typename
T
,
typename
Context
>
void
HardSwishRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
out
)
{
void
HardSwishKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
HardSwishOneDNNFunctor
<
T
>
functor
;
functor
(
dev_ctx
,
x
,
threshold
,
0
,
out
);
functor
(
dev_ctx
,
x
,
6
,
0
,
out
);
}
template
<
typename
T
,
typename
Context
>
...
...
@@ -202,7 +199,7 @@ PD_REGISTER_ACTIVATION_KERNEL(abs, AbsKernel)
PD_REGISTER_ACTIVATION_KERNEL
(
elu
,
EluKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
exp
,
ExpKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
gelu
,
GeluKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
_raw
,
HardSwishRaw
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
,
HardSwish
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
leaky_relu
,
LeakyReluKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
mish
,
MishKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
relu
,
ReluKernel
)
...
...
paddle/phi/kernels/xpu/activation_grad_kernel.cc
浏览文件 @
3e636ec9
...
...
@@ -603,11 +603,11 @@ template <typename T, typename Context>
void
HardSwishGradKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
dout
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
dx
)
{
XPUHardSwishGradFunctor
<
T
>
functor
;
float
threshold
=
6
;
float
scale
=
6
;
float
offset
=
3
;
auto
attrs
=
functor
.
GetAttrs
();
*
(
attrs
[
0
].
second
)
=
threshold
;
*
(
attrs
[
1
].
second
)
=
scale
;
...
...
paddle/phi/kernels/xpu/activation_kernel.cc
浏览文件 @
3e636ec9
...
...
@@ -513,13 +513,13 @@ DEFINE_XPU_ACTIVATION_KERNEL_WITH_TWO_ATTRS(HardSigmoid,
offset
)
template
<
typename
T
,
typename
Context
>
void
HardSwishRawKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
threshold
,
float
scale
,
float
offset
,
DenseTensor
*
out
)
{
void
HardSwishKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
XPUHardSwishFunctor
<
T
>
functor
;
float
threshold
=
6
;
float
scale
=
6
;
float
offset
=
3
;
auto
attrs
=
functor
.
GetAttrs
();
*
(
attrs
[
0
].
second
)
=
threshold
;
*
(
attrs
[
1
].
second
)
=
scale
;
...
...
@@ -551,7 +551,7 @@ PD_REGISTER_ACTIVATION_KERNEL(exp, ExpKernel) // no grad
PD_REGISTER_ACTIVATION_KERNEL
(
floor
,
FloorKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
leaky_relu
,
LeakyReluKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hard_sigmoid
,
HardSigmoidKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
_raw
,
HardSwishRaw
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hardswish
,
HardSwish
Kernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
mish
,
MishKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
pow
,
PowKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
reciprocal
,
ReciprocalKernel
)
...
...
paddle/phi/ops/compat/activation_sig.cc
浏览文件 @
3e636ec9
...
...
@@ -41,10 +41,6 @@ namespace phi {
DEFINE_ACT_GRAD_DEPX_OP_ARGMAP
(
HardTanh
,
"hardtanh"
,
"t_min"
comma
"t_max"
);
DEFINE_ACT_GRAD_DEPX_OP_ARGMAP
(
Mish
,
"mish"
,
"threshold"
);
DEFINE_ACT_GRAD_DEPX_OP_ARGMAP
(
HardSwish
,
"hardswish"
,
"threshold"
comma
"scale"
comma
"offset"
);
// NOLINT
DEFINE_ACT_GRAD_DEPX_OP_ARGMAP
(
Swish
,
"swish"
,
"beta"
);
// NOLINT
DEFINE_ACT_GRAD_DEPX_OP_ARGMAP
(
STanh
,
...
...
@@ -53,9 +49,13 @@ DEFINE_ACT_GRAD_DEPX_OP_ARGMAP(STanh,
DEFINE_ACT_GRAD_DEPOUT_OP_ARGMAP
(
Relu6
,
"relu6"
,
"threshold"
);
// NOLINT
KernelSignature
HardSwishGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"hardswish_grad"
,
{
"X"
,
"Out@GRAD"
},
{},
{
"X@GRAD"
});
}
KernelSignature
HardSwishOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"hardswish_raw"
,
{
"X"
},
{
"threshold"
,
"scale"
,
"offset"
},
{
"Out"
});
return
KernelSignature
(
"hardswish"
,
{
"X"
},
{},
{
"Out"
});
}
KernelSignature
SwishOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_swish.py
浏览文件 @
3e636ec9
...
...
@@ -40,9 +40,9 @@ class TrtConvertHardSwishTest(TrtLayerAutoScanTest):
def
generate_input1
(
attrs
:
List
[
Dict
[
str
,
Any
]]):
return
np
.
ones
([
1
,
3
,
32
,
32
]).
astype
(
np
.
float32
)
for
threshold
in
[
6.0
,
7.0
,
100.0
,
0.0
,
-
1.0
]:
for
scale
in
[
5.0
,
7.0
,
-
1.0
,
0.0
,
100
.0
]:
for
offset
in
[
3.0
,
5.0
,
-
1.0
,
0.0
,
100.0
]:
for
threshold
in
[
6.0
]:
for
scale
in
[
6
.0
]:
for
offset
in
[
3.0
]:
dics
=
[
{
"threshold"
:
threshold
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录