Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6bd7f860
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看板
未验证
提交
6bd7f860
编写于
8月 08, 2023
作者:
F
freeliuzc
提交者:
GitHub
8月 08, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize op structure (#55988)
上级
4728d58d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
9 addition
and
33 deletion
+9
-33
paddle/phi/api/yaml/fused_ops.yaml
paddle/phi/api/yaml/fused_ops.yaml
+1
-1
paddle/phi/infermeta/multiary.cc
paddle/phi/infermeta/multiary.cc
+6
-4
paddle/phi/infermeta/multiary.h
paddle/phi/infermeta/multiary.h
+0
-2
paddle/phi/kernels/fusion/gpu/fused_bias_act_kernel.cu
paddle/phi/kernels/fusion/gpu/fused_bias_act_kernel.cu
+2
-2
test/legacy_test/test_fused_bias_act_op.py
test/legacy_test/test_fused_bias_act_op.py
+0
-24
未找到文件。
paddle/phi/api/yaml/fused_ops.yaml
浏览文件 @
6bd7f860
...
...
@@ -83,7 +83,7 @@
optional
:
bias, x_max
-
op
:
fused_bias_act
args
:
(Tensor x, Tensor bias, Tensor dequant_scales, Tensor shift, Tensor smooth, str act_method = "gelu", str compute_dtype = "default",
int rows = -1, int cols = -1,
float quant_scale = -1, int quant_round_type = 1, float quant_max_bound = 127.0, float quant_min_bound = -127.0)
args
:
(Tensor x, Tensor bias, Tensor dequant_scales, Tensor shift, Tensor smooth, str act_method = "gelu", str compute_dtype = "default", float quant_scale = -1, int quant_round_type = 1, float quant_max_bound = 127.0, float quant_min_bound = -127.0)
output
:
Tensor(out)
infer_meta
:
func
:
FusedBiasActInferMeta
...
...
paddle/phi/infermeta/multiary.cc
浏览文件 @
6bd7f860
...
...
@@ -1342,8 +1342,6 @@ void FusedBiasActInferMeta(const MetaTensor& x,
const
MetaTensor
&
smooth
,
const
std
::
string
&
act_method
,
const
std
::
string
&
compute_dtype
,
int
rows
,
int
cols
,
float
quant_scale
,
int
quant_round_type
,
float
quant_max_bound
,
...
...
@@ -1358,10 +1356,14 @@ void FusedBiasActInferMeta(const MetaTensor& x,
auto
dim
=
x_dims
[
1
];
PADDLE_ENFORCE_GT
(
rows
,
0
,
phi
::
errors
::
InvalidArgument
(
"The size of Attr(rows) must > 0"
));
x_dims
[
0
],
0
,
phi
::
errors
::
InvalidArgument
(
"The size of Attr(rows) must > 0"
));
PADDLE_ENFORCE_GT
(
cols
,
0
,
phi
::
errors
::
InvalidArgument
(
"The size of Attr(cols) must > 0"
));
x_dims
[
1
],
0
,
phi
::
errors
::
InvalidArgument
(
"The size of Attr(cols) must > 0"
));
if
(
act_method
==
"geglu"
||
act_method
==
"swiglu"
)
{
PADDLE_ENFORCE_EQ
(
...
...
paddle/phi/infermeta/multiary.h
浏览文件 @
6bd7f860
...
...
@@ -286,8 +286,6 @@ void FusedBiasActInferMeta(const MetaTensor& x,
const
MetaTensor
&
smooth
,
const
std
::
string
&
act_method
,
const
std
::
string
&
compute_dtype
,
int
rows
,
int
cols
,
float
quant_scale
,
int
quant_round_type
,
float
quant_max_bound
,
...
...
paddle/phi/kernels/fusion/gpu/fused_bias_act_kernel.cu
浏览文件 @
6bd7f860
...
...
@@ -438,14 +438,14 @@ void FusedBiasActKernel(const Context &dev_ctx,
const
paddle
::
optional
<
DenseTensor
>
&
smooth
,
const
std
::
string
&
act_method
,
const
std
::
string
&
compute_dtype
,
int
rows
,
int
cols
,
float
quant_scale
,
int
quant_round_type
,
float
quant_max_bound
,
float
quant_min_bound
,
DenseTensor
*
out
)
{
#ifndef PADDLE_WITH_HIP
int
rows
=
x
.
dims
()[
0
];
int
cols
=
x
.
dims
()[
1
];
if
(
x
.
dtype
()
==
phi
::
DataType
::
INT32
)
{
if
(
compute_dtype
==
"bf16"
)
{
DispatchWithDtype
<
phi
::
dtype
::
bfloat16
,
Context
>
(
...
...
test/legacy_test/test_fused_bias_act_op.py
浏览文件 @
6bd7f860
...
...
@@ -73,8 +73,6 @@ def fused_act_bias_wrapper(
smooth
=
None
,
act_method
=
'gelu'
,
compute_dtype
=
'default'
,
rows
=
0
,
cols
=
0
,
quant_scale
=-
1
,
quant_round_type
=
0
,
quant_max_bound
=
0
,
...
...
@@ -88,8 +86,6 @@ def fused_act_bias_wrapper(
smooth
,
act_method
,
compute_dtype
,
rows
,
cols
,
quant_scale
,
quant_round_type
,
quant_max_bound
,
...
...
@@ -140,8 +136,6 @@ class TestFusedBiasActOp(unittest.TestCase):
return
fused_act_bias_wrapper
(
x
=
x
,
bias
=
bias
,
rows
=
self
.
rows
,
cols
=
self
.
cols
,
act_method
=
self
.
act_method
,
compute_dtype
=
self
.
compute_dtype
,
)
...
...
@@ -197,8 +191,6 @@ class TestFastGeluFP16(TestFusedBiasActOp):
out
=
fused_act_bias_wrapper
(
x
=
x
,
bias
=
bias
,
rows
=
self
.
rows
,
cols
=
self
.
cols
,
act_method
=
self
.
act_method
,
)
self
.
use_fast_math
(
False
)
...
...
@@ -284,8 +276,6 @@ class TestQuantFP32(TestFusedBiasActOp):
smooth
=
smooth
,
act_method
=
self
.
act_method
,
compute_dtype
=
self
.
compute_dtype
,
rows
=
self
.
rows
,
cols
=
self
.
cols
,
quant_scale
=
self
.
quant_scale
,
quant_round_type
=
self
.
quant_round_type
,
quant_max_bound
=
self
.
quant_max_bound
,
...
...
@@ -332,8 +322,6 @@ class TestDequantFP32(TestQuantFP32):
dequant_scales
=
dequant_scales
,
act_method
=
self
.
act_method
,
compute_dtype
=
self
.
compute_dtype
,
rows
=
self
.
rows
,
cols
=
self
.
cols
,
)
return
out
...
...
@@ -441,8 +429,6 @@ class TestFusedBiasActOpBF16(unittest.TestCase):
bias
=
bias
,
act_method
=
self
.
act_method
,
compute_dtype
=
self
.
compute_dtype
,
rows
=
self
.
rows
,
cols
=
self
.
cols
,
)
return
out
...
...
@@ -565,8 +551,6 @@ class TestQuantBF16(TestFusedBiasActOpBF16):
smooth
=
smooth
,
act_method
=
self
.
act_method
,
compute_dtype
=
self
.
compute_dtype
,
rows
=
self
.
rows
,
cols
=
self
.
cols
,
quant_scale
=
self
.
quant_scale
,
quant_round_type
=
self
.
quant_round_type
,
quant_max_bound
=
self
.
quant_max_bound
,
...
...
@@ -678,8 +662,6 @@ class TestAssert(unittest.TestCase):
out
=
fused_act_bias_wrapper
(
x
=
paddle
.
to_tensor
(
x
),
bias
=
paddle
.
to_tensor
(
bias
),
rows
=
self
.
rows
,
cols
=
self
.
cols
,
)
except
ValueError
as
e
:
pass
...
...
@@ -696,8 +678,6 @@ class TestAssert(unittest.TestCase):
out
=
fused_act_bias_wrapper
(
x
=
paddle
.
to_tensor
(
x
),
bias
=
paddle
.
to_tensor
(
bias
),
rows
=
self
.
rows
,
cols
=
self
.
cols
,
compute_dtype
=
'fp16'
,
)
except
ValueError
as
e
:
...
...
@@ -715,8 +695,6 @@ class TestAssert(unittest.TestCase):
out
=
fused_act_bias_wrapper
(
x
=
paddle
.
to_tensor
(
x
),
bias
=
paddle
.
to_tensor
(
bias
),
rows
=
self
.
rows
,
cols
=
self
.
cols
,
compute_dtype
=
'fp16'
,
act_method
=
act_method
,
)
...
...
@@ -765,8 +743,6 @@ class TestWithoutBias(unittest.TestCase):
return
fused_act_bias_wrapper
(
x
=
x
,
bias
=
None
,
rows
=
self
.
rows
,
cols
=
self
.
cols
,
act_method
=
self
.
act_method
,
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录