Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5073ea3c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
提交
5073ea3c
编写于
8月 24, 2020
作者:
C
chalsliu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support precision testing
上级
36868e84
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
183 addition
and
3 deletion
+183
-3
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+39
-3
tools/get_pr_ut.py
tools/get_pr_ut.py
+70
-0
tools/ut_filter.py
tools/ut_filter.py
+74
-0
未找到文件。
paddle/scripts/paddle_build.sh
浏览文件 @
5073ea3c
...
@@ -1031,6 +1031,38 @@ set -ex
...
@@ -1031,6 +1031,38 @@ set -ex
fi
fi
}
}
function
precision_test
()
{
if
[
${
WITH_TESTING
:-
ON
}
==
"ON"
]
;
then
cat
<<
EOF
========================================
Running precision unit tests ...
========================================
EOF
set
+x
EXIT_CODE
=
0
testcases
=
$1
if
[[
"
$testcases
"
==
""
]]
;
then
return
0
fi
card_test
"
$testcases
"
collect_failed_tests
if
[
-n
"
${
failed_test_lists
}
"
]
;
then
failed_test_lists_ult
=
`
echo
"
${
failed_test_lists
}
"
|grep
-Po
'[^ ].*$'
`
echo
"========================================"
echo
"Summary Failed Tests... "
echo
"========================================"
echo
"The following tests FAILED: "
echo
"
${
failed_test_lists_ult
}
"
fi
rm
-f
$tmp_dir
/
*
if
[[
"
$EXIT_CODE
"
!=
"0"
]]
;
then
exit
8
;
fi
set
-ex
fi
}
function
parallel_test_base_cpu
()
{
function
parallel_test_base_cpu
()
{
mkdir
-p
${
PADDLE_ROOT
}
/build
mkdir
-p
${
PADDLE_ROOT
}
/build
cd
${
PADDLE_ROOT
}
/build
cd
${
PADDLE_ROOT
}
/build
...
@@ -1055,10 +1087,14 @@ function parallel_test() {
...
@@ -1055,10 +1087,14 @@ function parallel_test() {
mkdir
-p
${
PADDLE_ROOT
}
/build
mkdir
-p
${
PADDLE_ROOT
}
/build
cd
${
PADDLE_ROOT
}
/build
cd
${
PADDLE_ROOT
}
/build
pip
install
${
PADDLE_ROOT
}
/build/python/dist/
*
whl
pip
install
${
PADDLE_ROOT
}
/build/python/dist/
*
whl
if
[
"
$
WITH_GPU
"
==
"ON"
]
;
then
if
[
"
$
{
CASES
}
"
!=
""
]
;
then
parallel_test_base_gpu
precision_test
$CASES
else
else
parallel_test_base_cpu
${
PROC_RUN
:-
1
}
if
[
"
$WITH_GPU
"
==
"ON"
]
;
then
parallel_test_base_gpu
else
parallel_test_base_cpu
${
PROC_RUN
:-
1
}
fi
fi
fi
ut_total_endTime_s
=
`
date
+%s
`
ut_total_endTime_s
=
`
date
+%s
`
echo
"TestCases Total Time:
$[
$ut_total_endTime_s
-
$ut_total_startTime_s
]s"
echo
"TestCases Total Time:
$[
$ut_total_endTime_s
-
$ut_total_startTime_s
]s"
...
...
tools/get_pr_ut.py
0 → 100644
浏览文件 @
5073ea3c
#!/bin/env python
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" For the PR that only modified the unit test, get cases in pull request. """
import
os
from
github
import
Github
import
ut_filter
PADDLE_ROOT
=
os
.
getenv
(
'PADDLE_ROOT'
,
'/paddle/'
)
class
PRChecker
(
object
):
""" PR Checker. """
def
__init__
(
self
):
self
.
github
=
Github
(
os
.
getenv
(
'GITHUB_API_TOKEN'
),
timeout
=
60
)
self
.
repo
=
self
.
github
.
get_repo
(
'PaddlePaddle/Paddle'
)
self
.
pr
=
None
def
init
(
self
):
""" Get pull request. """
pr_id
=
os
.
getenv
(
'GIT_PR_ID'
)
if
not
pr_id
:
print
(
'No PR ID'
)
exit
(
0
)
self
.
pr
=
self
.
repo
.
get_pull
(
int
(
pr_id
))
def
get_pr_files
(
self
):
""" Get files in pull request. """
page
=
0
file_list
=
[]
while
True
:
files
=
self
.
pr
.
get_files
().
get_page
(
page
)
if
not
files
:
break
for
f
in
files
:
file_list
.
append
(
PADDLE_ROOT
+
f
.
filename
)
page
+=
1
return
file_list
#return ['/paddle/paddle/fluid/memory/malloc_test.cu']
def
get_pr_ut
(
self
):
""" Get unit tests in pull request. """
ut_str
=
''
ut_mapper
=
ut_filter
.
UTMapper
()
file_ut_map
=
ut_mapper
.
get_src_ut_map
()
for
f
in
self
.
get_pr_files
():
if
f
not
in
file_ut_map
:
return
''
else
:
ut_str
=
'{}^{}$|'
.
format
(
ut_str
,
file_ut_map
[
f
])
return
ut_str
.
rstrip
(
'|'
)
if
__name__
==
'__main__'
:
pr_checker
=
PRChecker
()
pr_checker
.
init
()
print
(
pr_checker
.
get_pr_ut
())
tools/ut_filter.py
0 → 100644
浏览文件 @
5073ea3c
#!/bin/env python
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Build file and unit test mapping. """
import
os
import
re
import
json
import
time
import
os.path
import
subprocess
from
github
import
Github
PADDLE_ROOT
=
os
.
getenv
(
'PADDLE_ROOT'
,
'/paddle/'
)
class
UTMapper
(
object
):
""" Unit test mapper. """
def
__init__
(
self
):
self
.
github
=
Github
(
os
.
getenv
(
'GITHUB_API_TOKEN'
),
timeout
=
60
)
self
.
repo
=
None
self
.
ut_list
=
[]
self
.
src_ut_dict
=
{}
def
load_ctest_ut_list
(
self
):
""" Load ctest unit test list. """
ps
=
subprocess
.
Popen
(
"ctest -N | awk -F ':' '{print $2}' | sed '/^$/d' | sed '$d' | sed 's/ //g'"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
cwd
=
'{}build'
.
format
(
PADDLE_ROOT
))
uts
=
ps
.
communicate
()[
0
]
self
.
ut_list
=
uts
.
rstrip
(
'
\n
'
).
split
(
'
\n
'
)
def
load_cpp_and_cuda_ut
(
self
):
""" Load C++ and CUDA unit test list. """
data
=
None
cpp_cuda_ut_file
=
'{}build/compile_commands.json'
.
format
(
PADDLE_ROOT
)
with
open
(
cpp_cuda_ut_file
)
as
f
:
data
=
json
.
load
(
f
)
for
ut
in
data
:
ut_name
=
re
.
search
(
'-o .*\/(.*).dir\/.*'
,
ut
[
'command'
]).
group
(
1
)
if
ut_name
not
in
self
.
ut_list
:
continue
self
.
src_ut_dict
[
ut
[
'file'
]]
=
ut_name
def
load_python_ut
(
self
):
""" Load Python unit test list. """
pyut_files
=
subprocess
.
check_output
(
'find {}python -name test*.py'
.
format
(
PADDLE_ROOT
).
split
(
' '
))
pyut_list
=
pyut_files
.
rstrip
(
'
\n
'
).
split
(
'
\n
'
)
for
src_file
in
pyut_list
:
self
.
src_ut_dict
[
src_file
]
=
src_file
.
split
(
'/'
)[
-
1
].
split
(
'.py'
)[
0
]
def
get_src_ut_map
(
self
):
""" Get src file and unit test map. """
self
.
load_ctest_ut_list
()
self
.
load_cpp_and_cuda_ut
()
self
.
load_python_ut
()
return
self
.
src_ut_dict
if
__name__
==
'__main__'
:
ut_mapper
=
UTMapper
()
ut_mapper
.
load_python_ut
()
ut_mapper
.
load_ctest_ut_list
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录