Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9aed8327
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
9aed8327
编写于
5月 23, 2022
作者:
R
Ruibiao Chen
提交者:
GitHub
5月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce test case for test_tensordot (#42885)
* Reduce test case for test_tensordot * Fix CI errors
上级
65f705e1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
65 deletion
+38
-65
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+3
-1
python/paddle/fluid/tests/unittests/test_tensordot.py
python/paddle/fluid/tests/unittests/test_tensordot.py
+35
-64
未找到文件。
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
9aed8327
...
...
@@ -185,6 +185,8 @@ endif()
# Temporally disable test_deprecated_decorator
LIST
(
REMOVE_ITEM TEST_OPS test_deprecated_decorator
)
LIST
(
REMOVE_ITEM TEST_OPS test_tensordot
)
if
(
WIN32
)
LIST
(
REMOVE_ITEM TEST_OPS test_multiprocess_reader_exception
)
LIST
(
REMOVE_ITEM TEST_OPS test_trainer_desc
)
...
...
@@ -1036,7 +1038,7 @@ set_tests_properties(test_imperative_selected_rows_to_lod_tensor PROPERTIES TIME
set_tests_properties
(
test_index_select_op PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_parallel_ssa_graph_inference_feed_partial_data PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_parallel_executor_crf PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_tensordot PROPERTIES TIMEOUT 200
)
#
set_tests_properties(test_tensordot PROPERTIES TIMEOUT 200)
set_tests_properties
(
test_imperative_save_load PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_partial_eager_deletion_transformer PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_parallel_executor_seresnext_with_reduce_gpu PROPERTIES TIMEOUT 120
)
...
...
python/paddle/fluid/tests/unittests/test_tensordot.py
浏览文件 @
9aed8327
...
...
@@ -89,65 +89,6 @@ class TestTensordotAPI(unittest.TestCase):
self
.
x
=
np
.
random
.
random
(
self
.
x_shape
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
random
(
self
.
y_shape
).
astype
(
self
.
dtype
)
def
set_test_axes
(
self
):
self
.
all_axes
=
[]
axial_index
=
range
(
4
)
all_permutations
=
list
(
it
.
permutations
(
axial_index
,
0
))
+
list
(
it
.
permutations
(
axial_index
,
1
))
+
list
(
it
.
permutations
(
axial_index
,
2
))
+
list
(
it
.
permutations
(
axial_index
,
3
))
+
list
(
it
.
permutations
(
axial_index
,
4
))
self
.
all_axes
.
extend
(
list
(
i
)
for
i
in
all_permutations
)
for
axes_x
in
all_permutations
:
for
axes_y
in
all_permutations
:
if
len
(
axes_x
)
<
len
(
axes_y
):
supplementary_axes_x
=
axes_x
+
axes_y
[
len
(
axes_x
):]
if
any
(
supplementary_axes_x
.
count
(
i
)
>
1
for
i
in
supplementary_axes_x
):
continue
elif
len
(
axes_y
)
<
len
(
axes_x
):
supplementary_axes_y
=
axes_y
+
axes_x
[
len
(
axes_y
):]
if
any
(
supplementary_axes_y
.
count
(
i
)
>
1
for
i
in
supplementary_axes_y
):
continue
self
.
all_axes
.
append
([
list
(
axes_x
),
list
(
axes_y
)])
self
.
all_axes
.
extend
(
range
(
5
))
def
test_dygraph
(
self
):
paddle
.
disable_static
()
for
axes
in
self
.
all_axes
:
for
place
in
self
.
places
:
x
=
paddle
.
to_tensor
(
self
.
x
,
place
=
place
)
y
=
paddle
.
to_tensor
(
self
.
y
,
place
=
place
)
paddle_res
=
paddle
.
tensordot
(
x
,
y
,
axes
)
np_res
=
tensordot_np
(
self
.
x
,
self
.
y
,
axes
)
np
.
testing
.
assert_allclose
(
paddle_res
,
np_res
,
rtol
=
1e-6
)
def
test_static
(
self
):
paddle
.
enable_static
()
for
axes
in
self
.
all_axes
:
for
place
in
self
.
places
:
with
paddle
.
static
.
program_guard
(
paddle
.
static
.
Program
(),
paddle
.
static
.
Program
()):
x
=
paddle
.
static
.
data
(
name
=
'x'
,
shape
=
self
.
x_shape
,
dtype
=
self
.
dtype
)
y
=
paddle
.
static
.
data
(
name
=
'y'
,
shape
=
self
.
y_shape
,
dtype
=
self
.
dtype
)
z
=
paddle
.
tensordot
(
x
,
y
,
axes
)
exe
=
paddle
.
static
.
Executor
(
place
)
paddle_res
=
exe
.
run
(
feed
=
{
'x'
:
self
.
x
,
'y'
:
self
.
y
},
fetch_list
=
[
z
])
np_res
=
tensordot_np
(
self
.
x
,
self
.
y
,
axes
)
np
.
testing
.
assert_allclose
(
paddle_res
[
0
],
np_res
,
rtol
=
1e-6
)
class
TestTensordotAPIFloat64
(
TestTensordotAPI
):
# Only test a small part of axes case for Float64 type
def
set_test_axes
(
self
):
self
.
all_axes
=
[
[[
3
,
2
],
[
3
]],
[[
2
,
1
,
0
],
[
2
,
1
]],
[[
1
,
2
,
0
],
[
1
,
3
,
2
]],
[
3
,
0
],
...
...
@@ -194,35 +135,65 @@ class TestTensordotAPIFloat64(TestTensordotAPI):
[[
2
,
0
,
1
],
[
0
,
1
,
3
]],
[[
2
,
1
],
[
0
,
1
,
3
]]
]
def
test_dygraph
(
self
):
paddle
.
disable_static
()
for
axes
in
self
.
all_axes
:
for
place
in
self
.
places
:
x
=
paddle
.
to_tensor
(
self
.
x
,
place
=
place
)
y
=
paddle
.
to_tensor
(
self
.
y
,
place
=
place
)
paddle_res
=
paddle
.
tensordot
(
x
,
y
,
axes
)
np_res
=
tensordot_np
(
self
.
x
,
self
.
y
,
axes
)
np
.
testing
.
assert_allclose
(
paddle_res
,
np_res
,
rtol
=
1e-6
)
def
test_static
(
self
):
paddle
.
enable_static
()
for
axes
in
self
.
all_axes
:
for
place
in
self
.
places
:
with
paddle
.
static
.
program_guard
(
paddle
.
static
.
Program
(),
paddle
.
static
.
Program
()):
x
=
paddle
.
static
.
data
(
name
=
'x'
,
shape
=
self
.
x_shape
,
dtype
=
self
.
dtype
)
y
=
paddle
.
static
.
data
(
name
=
'y'
,
shape
=
self
.
y_shape
,
dtype
=
self
.
dtype
)
z
=
paddle
.
tensordot
(
x
,
y
,
axes
)
exe
=
paddle
.
static
.
Executor
(
place
)
paddle_res
=
exe
.
run
(
feed
=
{
'x'
:
self
.
x
,
'y'
:
self
.
y
},
fetch_list
=
[
z
])
np_res
=
tensordot_np
(
self
.
x
,
self
.
y
,
axes
)
np
.
testing
.
assert_allclose
(
paddle_res
[
0
],
np_res
,
rtol
=
1e-6
)
class
TestTensordotAPIFloat64
(
TestTensordotAPI
):
def
set_dtype
(
self
):
self
.
dtype
=
np
.
float64
class
TestTensordotAPIBroadcastCase1
(
TestTensordotAPI
Float64
):
class
TestTensordotAPIBroadcastCase1
(
TestTensordotAPI
):
def
set_input_shape
(
self
):
self
.
x_shape
=
[
1
,
1
,
1
,
5
]
self
.
y_shape
=
[
1
,
5
,
1
,
1
]
class
TestTensordotAPIBroadcastCase2
(
TestTensordotAPI
Float64
):
class
TestTensordotAPIBroadcastCase2
(
TestTensordotAPI
):
def
set_input_shape
(
self
):
self
.
x_shape
=
[
1
,
5
,
5
,
5
]
self
.
y_shape
=
[
1
,
1
,
1
,
5
]
class
TestTensordotAPIBroadcastCase3
(
TestTensordotAPI
Float64
):
class
TestTensordotAPIBroadcastCase3
(
TestTensordotAPI
):
def
set_input_shape
(
self
):
self
.
x_shape
=
[
5
,
5
,
5
,
1
]
self
.
y_shape
=
[
5
,
5
,
1
,
5
]
class
TestTensordotAPIBroadcastCase4
(
TestTensordotAPI
Float64
):
class
TestTensordotAPIBroadcastCase4
(
TestTensordotAPI
):
def
set_input_shape
(
self
):
self
.
x_shape
=
[
5
,
5
,
5
,
1
]
self
.
y_shape
=
[
1
,
1
,
1
,
1
]
class
TestTensordotAPIBroadcastCase5
(
TestTensordotAPI
Float64
):
class
TestTensordotAPIBroadcastCase5
(
TestTensordotAPI
):
def
set_input_shape
(
self
):
self
.
x_shape
=
[
1
,
1
,
5
,
5
]
self
.
y_shape
=
[
5
,
5
,
1
,
5
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录