Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b561a05e
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看板
未验证
提交
b561a05e
编写于
8月 10, 2023
作者:
Y
Yuang Liu
提交者:
GitHub
8月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix A100 fused linear grad add ut bug (#56136)
上级
7c4a3556
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
23 deletion
+40
-23
test/legacy_test/test_fused_linear_param_grad_add.py
test/legacy_test/test_fused_linear_param_grad_add.py
+39
-22
tools/gpups_test.sh
tools/gpups_test.sh
+1
-1
未找到文件。
test/legacy_test/test_fused_linear_param_grad_add.py
浏览文件 @
b561a05e
...
...
@@ -54,7 +54,7 @@ def recreate(x, multi_precision):
return
paddle
.
to_tensor
(
x
.
numpy
())
def
run_ground_truth
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
):
def
run_ground_truth
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
,
has_bias
):
x
,
dy
,
dweight
,
dbias
=
recreate
([
x
,
dy
,
dweight
,
dbias
],
multi_precision
)
dweight_tmp
=
paddle
.
matmul
(
...
...
@@ -69,24 +69,35 @@ def run_ground_truth(x, dy, dweight, dbias, multi_precision):
assert
dweight
.
dtype
==
dweight
.
dtype
dweight
+=
dweight_tmp
dbias_tmp
=
dy
.
reshape
([
-
1
,
dy
.
shape
[
-
1
]]).
sum
(
axis
=
0
)
if
dbias
is
None
:
dbias
=
dbias_tmp
else
:
assert
dbias
.
shape
==
dbias_tmp
.
shape
assert
dbias
.
dtype
==
dbias_tmp
.
dtype
dbias
+=
dbias_tmp
if
has_bias
:
dbias_tmp
=
dy
.
reshape
([
-
1
,
dy
.
shape
[
-
1
]]).
sum
(
axis
=
0
)
if
dbias
is
None
:
dbias
=
dbias_tmp
else
:
assert
dbias
.
shape
==
dbias_tmp
.
shape
assert
dbias
.
dtype
==
dbias_tmp
.
dtype
dbias
+=
dbias_tmp
return
promote_dtype
(
dweight
).
numpy
(),
promote_dtype
(
dbias
).
numpy
()
return
promote_dtype
(
dweight
).
numpy
(),
promote_dtype
(
dbias
).
numpy
()
else
:
return
promote_dtype
(
dweight
).
numpy
()
def
run_fused_linear_param_grad_add
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
):
def
run_fused_linear_param_grad_add
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
,
has_bias
):
dweight_new
,
dbias_new
=
_C_ops
.
fused_linear_param_grad_add
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
x
,
dy
,
dweight
,
dbias
,
multi_precision
,
has_bias
)
if
dweight
is
not
None
:
assert
dweight_new
.
data_ptr
()
==
dweight
.
data_ptr
()
return
promote_dtype
(
dweight_new
).
numpy
(),
promote_dtype
(
dbias_new
).
numpy
()
if
has_bias
:
return
(
promote_dtype
(
dweight_new
).
numpy
(),
promote_dtype
(
dbias_new
).
numpy
(),
)
else
:
return
promote_dtype
(
dweight_new
).
numpy
()
class
TestMainClassBase
(
unittest
.
TestCase
):
...
...
@@ -103,7 +114,9 @@ class TestMainClassBase(unittest.TestCase):
x
=
paddle
.
to_tensor
(
x
)
return
x
.
astype
(
dtype
or
self
.
dtype
)
def
generate_rand_inputs
(
self
,
has_dweight
,
has_dbias
,
multi_precision
):
def
generate_rand_inputs
(
self
,
has_dweight
,
has_dbias
,
multi_precision
,
has_bias
):
x_shape
=
self
.
shape
dy_shape
=
self
.
shape
[:
-
1
]
+
[
self
.
output_size
]
dweight_shape
=
[
self
.
shape
[
-
1
],
self
.
output_size
]
...
...
@@ -118,7 +131,7 @@ class TestMainClassBase(unittest.TestCase):
else
:
dweight
=
None
if
has_dbias
:
if
has_
bias
and
has_
dbias
:
dbias
=
self
.
rand
(
dbias_shape
)
if
multi_precision
:
dbias
=
promote_dtype
(
dbias
)
...
...
@@ -126,14 +139,15 @@ class TestMainClassBase(unittest.TestCase):
dbias
=
None
return
x
,
dy
,
dweight
,
dbias
def
check_main
(
self
,
has_dweight
,
has_dbias
,
multi_precision
):
print
(
has_dweight
,
has_dbias
,
multi_precision
)
def
check_main
(
self
,
has_dweight
,
has_dbias
,
multi_precision
,
has_bias
):
x
,
dy
,
dweight
,
dbias
=
self
.
generate_rand_inputs
(
has_dweight
,
has_dbias
,
multi_precision
has_dweight
,
has_dbias
,
multi_precision
,
has_bias
)
res1
=
run_ground_truth
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
,
has_bias
)
res1
=
run_ground_truth
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
)
res2
=
run_fused_linear_param_grad_add
(
x
,
dy
,
dweight
,
dbias
,
multi_precision
x
,
dy
,
dweight
,
dbias
,
multi_precision
,
has_bias
)
self
.
assertEqual
(
len
(
res1
),
len
(
res2
))
for
r1
,
r2
in
zip
(
res1
,
res2
):
...
...
@@ -153,9 +167,12 @@ class TestMainClassBase(unittest.TestCase):
return
for
has_dweight
in
[
False
,
True
]:
for
has_dbias
in
[
False
,
True
]:
for
multi_precision
in
[
False
,
True
]:
self
.
check_main
(
has_dweight
,
has_dbias
,
multi_precision
)
for
has_bias
in
[
False
,
True
]:
for
has_dbias
in
[
False
,
True
]:
for
multi_precision
in
[
False
,
True
]:
self
.
check_main
(
has_dweight
,
has_dbias
,
multi_precision
,
has_bias
)
class
TestMainClassBF16
(
TestMainClassBase
):
...
...
tools/gpups_test.sh
浏览文件 @
b561a05e
...
...
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Disable Test list: test_fused_linear_param_grad_add
serial_list
=
"^test_conv2d_op
$|
\
^test_conv2d_transpose_op
$|
\
...
...
@@ -69,6 +68,7 @@ parallel_list="^init_phi_test$|\
^test_fused_gemm_epilogue_op
$|
\
^test_fused_gemm_epilogue_op_with_es
$|
\
^test_fused_layernorm_residual_dropout_bias
$|
\
^test_fused_linear_param_grad_add
$|
\
^test_fused_linear_pass
$|
\
^test_fused_matmul_bias
$|
\
^test_fused_multi_transformer_decoder_pass
$|
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录