Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
d95293f3
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看板
未验证
提交
d95293f3
编写于
6月 07, 2022
作者:
W
Weilong Wu
提交者:
GitHub
6月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager] fix 2 fused op test and add retain_grad flag under eager (#43258)
上级
8c3777df
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
36 addition
and
26 deletion
+36
-26
python/paddle/fluid/tests/unittests/test_fused_bias_dropout_residual_layer_norm_op.py
...ittests/test_fused_bias_dropout_residual_layer_norm_op.py
+3
-1
python/paddle/fluid/tests/unittests/test_fused_gate_attention_op.py
...dle/fluid/tests/unittests/test_fused_gate_attention_op.py
+3
-1
python/paddle/fluid/tests/unittests/test_tensor_fill_diagonal_tensor.py
...fluid/tests/unittests/test_tensor_fill_diagonal_tensor.py
+30
-24
未找到文件。
python/paddle/fluid/tests/unittests/test_fused_bias_dropout_residual_layer_norm_op.py
浏览文件 @
d95293f3
...
@@ -26,7 +26,9 @@ from paddle import tensor
...
@@ -26,7 +26,9 @@ from paddle import tensor
from
paddle.fluid
import
layers
from
paddle.fluid
import
layers
import
unittest
import
unittest
from
op_test
import
OpTest
from
op_test
import
OpTest
from
paddle.fluid.framework
import
default_main_program
from
paddle.fluid.framework
import
default_main_program
,
_enable_legacy_dygraph
_enable_legacy_dygraph
()
default_main_program
().
random_seed
=
42
default_main_program
().
random_seed
=
42
...
...
python/paddle/fluid/tests/unittests/test_fused_gate_attention_op.py
浏览文件 @
d95293f3
...
@@ -21,9 +21,11 @@ import unittest
...
@@ -21,9 +21,11 @@ import unittest
from
op_test
import
OpTest
,
convert_float_to_uint16
from
op_test
import
OpTest
,
convert_float_to_uint16
from
test_sparse_attention_op
import
get_cuda_version
from
test_sparse_attention_op
import
get_cuda_version
from
paddle
import
_C_ops
from
paddle
import
_C_ops
from
paddle.fluid.framework
import
default_main_program
from
paddle.fluid.framework
import
default_main_program
,
_enable_legacy_dygraph
from
paddle.fluid
import
core
from
paddle.fluid
import
core
_enable_legacy_dygraph
()
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
(),
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
(),
"Paddle is not compiled with CUDA"
)
"Paddle is not compiled with CUDA"
)
...
...
python/paddle/fluid/tests/unittests/test_tensor_fill_diagonal_tensor.py
浏览文件 @
d95293f3
...
@@ -30,10 +30,10 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
...
@@ -30,10 +30,10 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
def
test_dim2
(
self
):
def
test_dim2
(
self
):
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
expected_np
=
np
.
array
(
expected_np
=
np
.
array
(
[[
1
,
2
,
2
],
[
2
,
1
,
2
],
[
2
,
2
,
1
],
[[
1
,
2
,
2
],
[
2
,
1
,
2
],
[
2
,
2
,
1
],
[
2
,
2
,
2
]]).
astype
(
'float32'
)
[
2
,
2
,
2
]]).
astype
(
'float32'
)
expected_grad
=
np
.
array
(
expected_grad
=
np
.
array
(
[[
0
,
1
,
1
],
[
1
,
0
,
1
],
[
1
,
1
,
0
],
[[
0
,
1
,
1
],
[
1
,
0
,
1
],
[
1
,
1
,
0
],
[
1
,
1
,
1
]]).
astype
(
'float32'
)
[
1
,
1
,
1
]]).
astype
(
'float32'
)
for
idx
,
p
in
enumerate
(
self
.
places
):
for
idx
,
p
in
enumerate
(
self
.
places
):
if
idx
==
0
:
if
idx
==
0
:
...
@@ -59,10 +59,10 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
...
@@ -59,10 +59,10 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
def
test_dim2_offset_1
(
self
):
def
test_dim2_offset_1
(
self
):
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
expected_np
=
np
.
array
(
expected_np
=
np
.
array
(
[[
2
,
2
,
2
],
[
1
,
2
,
2
],
[
2
,
1
,
2
],
[[
2
,
2
,
2
],
[
1
,
2
,
2
],
[
2
,
1
,
2
],
[
2
,
2
,
1
]]).
astype
(
'float32'
)
[
2
,
2
,
1
]]).
astype
(
'float32'
)
expected_grad
=
np
.
array
(
expected_grad
=
np
.
array
(
[[
1
,
1
,
1
],
[
0
,
1
,
1
],
[
1
,
0
,
1
],
[[
1
,
1
,
1
],
[
0
,
1
,
1
],
[
1
,
0
,
1
],
[
1
,
1
,
0
]]).
astype
(
'float32'
)
[
1
,
1
,
0
]]).
astype
(
'float32'
)
for
idx
,
p
in
enumerate
(
self
.
places
):
for
idx
,
p
in
enumerate
(
self
.
places
):
if
idx
==
0
:
if
idx
==
0
:
...
@@ -88,10 +88,10 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
...
@@ -88,10 +88,10 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
def
test_dim2_offset1
(
self
):
def
test_dim2_offset1
(
self
):
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
expected_np
=
np
.
array
(
expected_np
=
np
.
array
(
[[
2
,
1
,
2
],
[
2
,
2
,
1
],
[
2
,
2
,
2
],
[[
2
,
1
,
2
],
[
2
,
2
,
1
],
[
2
,
2
,
2
],
[
2
,
2
,
2
]]).
astype
(
'float32'
)
[
2
,
2
,
2
]]).
astype
(
'float32'
)
expected_grad
=
np
.
array
(
expected_grad
=
np
.
array
(
[[
1
,
0
,
1
],
[
1
,
1
,
0
],
[
1
,
1
,
1
],
[[
1
,
0
,
1
],
[
1
,
1
,
0
],
[
1
,
1
,
1
],
[
1
,
1
,
1
]]).
astype
(
'float32'
)
[
1
,
1
,
1
]]).
astype
(
'float32'
)
for
idx
,
p
in
enumerate
(
self
.
places
):
for
idx
,
p
in
enumerate
(
self
.
places
):
if
idx
==
0
:
if
idx
==
0
:
...
@@ -117,16 +117,20 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
...
@@ -117,16 +117,20 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
def
test_dim4
(
self
):
def
test_dim4
(
self
):
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
expected_np
=
np
.
array
(
expected_np
=
np
.
array
([[[[
0
,
3
],
[
2
,
2
],
[
2
,
2
]],
[[[[
0
,
3
],
[
2
,
2
],
[
2
,
2
]],
[[
2
,
2
],
[
1
,
4
],
[
2
,
2
]],
[[
2
,
2
],
[
1
,
4
],
[
2
,
2
]],
[[
2
,
2
],
[
2
,
2
],
[
2
,
5
]],
[[
2
,
2
],
[
2
,
2
],
[
2
,
2
]]],
[[
2
,
2
],
[
2
,
2
],
[
2
,
5
]],
[[[
6
,
9
],
[
2
,
2
],
[
2
,
2
]],
[[
2
,
2
],
[
7
,
10
],
[
2
,
2
]],
[[
2
,
2
],
[
2
,
2
],
[
2
,
2
]]],
[[[
6
,
9
],
[
2
,
2
],
[
2
,
2
]],
[[
2
,
2
],
[
7
,
10
],
[
2
,
2
]],
[[
2
,
2
],
[
2
,
2
],
[
8
,
11
]],
[[
2
,
2
],
[
2
,
2
],
[
8
,
11
]],
[[
2
,
2
],
[
2
,
2
],
[
2
,
2
]]]]).
astype
(
'float32'
)
[[
2
,
2
],
[
2
,
2
],
[
2
,
2
]]]]).
astype
(
'float32'
)
expected_grad
=
np
.
array
(
expected_grad
=
np
.
array
([[[[
0
,
0
],
[
1
,
1
],
[
1
,
1
]],
[[[[
0
,
0
],
[
1
,
1
],
[
1
,
1
]],
[[
1
,
1
],
[
0
,
0
],
[
1
,
1
]],
[[
1
,
1
],
[
0
,
0
],
[
1
,
1
]],
[[
1
,
1
],
[
1
,
1
],
[
0
,
0
]],
[[
1
,
1
],
[
1
,
1
],
[
1
,
1
]]],
[[
1
,
1
],
[
1
,
1
],
[
0
,
0
]],
[[[
0
,
0
],
[
1
,
1
],
[
1
,
1
]],
[[
1
,
1
],
[
0
,
0
],
[
1
,
1
]],
[[
1
,
1
],
[
1
,
1
],
[
1
,
1
]]],
[[[
0
,
0
],
[
1
,
1
],
[
1
,
1
]],
[[
1
,
1
],
[
0
,
0
],
[
1
,
1
]],
[[
1
,
1
],
[
1
,
1
],
[
0
,
0
]],
[[
1
,
1
],
[
1
,
1
],
[
0
,
0
]],
[[
1
,
1
],
[
1
,
1
],
[
1
,
1
]]]]).
astype
(
'float32'
)
[[
1
,
1
],
[
1
,
1
],
[
1
,
1
]]]]).
astype
(
'float32'
)
...
@@ -154,6 +158,7 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
...
@@ -154,6 +158,7 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
False
})
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
False
})
def
test_largedim
(
self
):
def
test_largedim
(
self
):
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
True
})
if
len
(
self
.
places
)
>
1
:
if
len
(
self
.
places
)
>
1
:
bsdim
=
1024
bsdim
=
1024
fsdim
=
128
fsdim
=
128
...
@@ -175,6 +180,7 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
...
@@ -175,6 +180,7 @@ class TensorFillDiagTensor_Test(unittest.TestCase):
self
.
assertEqual
((
ny
==
expected_pred
).
all
(),
True
)
self
.
assertEqual
((
ny
==
expected_pred
).
all
(),
True
)
self
.
assertEqual
((
y
.
grad
==
expected_grad
).
all
(),
True
)
self
.
assertEqual
((
y
.
grad
==
expected_grad
).
all
(),
True
)
fluid
.
set_flags
({
"FLAGS_retain_grad_for_all_tensor"
:
False
})
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录