Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a3bd6fc0
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看板
未验证
提交
a3bd6fc0
编写于
12月 18, 2021
作者:
王
王明冬
提交者:
GitHub
12月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[infrt] add unit test script for infrt. test=develop (#38232)
上级
1bb2c68a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
224 addition
and
19 deletion
+224
-19
cmake/external/llvm.cmake
cmake/external/llvm.cmake
+1
-1
cmake/infrt_lib.cmake
cmake/infrt_lib.cmake
+77
-0
paddle/infrt/CMakeLists.txt
paddle/infrt/CMakeLists.txt
+4
-1
paddle/infrt/dialect/CMakeLists.txt
paddle/infrt/dialect/CMakeLists.txt
+9
-17
paddle/infrt/dialect/mlir_tests/dense_tensor.mlir
paddle/infrt/dialect/mlir_tests/dense_tensor.mlir
+1
-0
paddle/scripts/infrt_build.sh
paddle/scripts/infrt_build.sh
+132
-0
未找到文件。
cmake/external/llvm.cmake
浏览文件 @
a3bd6fc0
...
...
@@ -106,5 +106,5 @@ endfunction()
# @script: path to the mlir script file
function
(
infrt_exec_check name script
)
add_test
(
NAME
${
name
}
COMMAND sh -c
"
${
CMAKE_BINARY_DIR
}
/infrt/host_context/infrt-exec -i
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
script
}
|
${
LLVM_PATH
}
/bin/FileCheck
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
script
}
"
)
COMMAND sh -c
"
${
CMAKE_BINARY_DIR
}
/
paddle/
infrt/host_context/infrt-exec -i
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
script
}
|
${
LLVM_PATH
}
/bin/FileCheck
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
script
}
"
)
endfunction
()
cmake/infrt_lib.cmake
0 → 100644
浏览文件 @
a3bd6fc0
# Copyright (c) 2021 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.
set
(
PADDLE_INFRT_INSTALL_DIR
"
${
CMAKE_BINARY_DIR
}
/paddle_infrt_install_dir"
CACHE STRING
"A path setting paddle infrt shared and static libraries"
)
function
(
copy TARGET
)
set
(
options
""
)
set
(
oneValueArgs
""
)
set
(
multiValueArgs SRCS DSTS
)
cmake_parse_arguments
(
copy_lib
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
list
(
LENGTH copy_lib_SRCS copy_lib_SRCS_len
)
list
(
LENGTH copy_lib_DSTS copy_lib_DSTS_len
)
if
(
NOT
${
copy_lib_SRCS_len
}
EQUAL
${
copy_lib_DSTS_len
}
)
message
(
FATAL_ERROR
"
${
TARGET
}
source numbers are not equal to destination numbers"
)
endif
()
math
(
EXPR len
"
${
copy_lib_SRCS_len
}
- 1"
)
foreach
(
index RANGE
${
len
}
)
list
(
GET copy_lib_SRCS
${
index
}
src
)
list
(
GET copy_lib_DSTS
${
index
}
dst
)
add_custom_command
(
TARGET
${
TARGET
}
POST_BUILD
COMMAND mkdir -p
"
${
dst
}
"
COMMAND cp -r
"
${
src
}
"
"
${
dst
}
"
COMMENT
"copying
${
src
}
->
${
dst
}
"
)
endforeach
()
endfunction
()
function
(
copy_part_of_thrid_party TARGET DST
)
set
(
dst_dir
"
${
DST
}
/third_party/install/glog"
)
copy
(
${
TARGET
}
SRCS
${
GLOG_INCLUDE_DIR
}
${
GLOG_LIBRARIES
}
DSTS
${
dst_dir
}
${
dst_dir
}
/lib
)
endfunction
()
# inference library for only inference
set
(
infrt_lib_deps third_party infrt infrt_static
)
add_custom_target
(
infrt_lib_dist DEPENDS
${
infrt_lib_deps
}
)
# CMakeCache Info
copy
(
infrt_lib_dist
SRCS
${
CMAKE_BINARY_DIR
}
/CMakeCache.txt
DSTS
${
PADDLE_INFRT_INSTALL_DIR
}
)
set
(
src_dir
"
${
PADDLE_SOURCE_DIR
}
/paddle/infrt"
)
set
(
paddle_infrt_lib
${
PADDLE_BINARY_DIR
}
/paddle/infrt/libinfrt.*
)
copy
(
infrt_lib_dist
SRCS
${
src_dir
}
/api/infrt_api.h
${
paddle_infrt_lib
}
DSTS
${
PADDLE_INFRT_INSTALL_DIR
}
/infrt/include
${
PADDLE_INFRT_INSTALL_DIR
}
/infrt/lib
)
copy
(
infrt_lib_dist
SRCS
${
CMAKE_BINARY_DIR
}
/paddle/infrt/paddle/framework.pb.h
DSTS
${
PADDLE_INFRT_INSTALL_DIR
}
/infrt/include/internal
)
# paddle fluid version
function
(
version version_file
)
execute_process
(
COMMAND
${
GIT_EXECUTABLE
}
log --pretty=format:%H -1
WORKING_DIRECTORY
${
PADDLE_SOURCE_DIR
}
OUTPUT_VARIABLE PADDLE_GIT_COMMIT
)
file
(
WRITE
${
version_file
}
"GIT COMMIT ID:
${
PADDLE_GIT_COMMIT
}
\n
"
)
file
(
APPEND
${
version_file
}
"CXX compiler version:
${
CMAKE_CXX_COMPILER_VERSION
}
\n
"
)
endfunction
()
version
(
${
PADDLE_INFRT_INSTALL_DIR
}
/version.txt
)
paddle/infrt/CMakeLists.txt
浏览文件 @
a3bd6fc0
...
...
@@ -2,6 +2,8 @@ if (NOT WITH_INFRT)
return
()
endif
()
include
(
infrt_lib
)
set
(
infrt_src CACHE INTERNAL
""
FORCE
)
# Gather headers for library publish.
...
...
@@ -75,5 +77,6 @@ set(infrt_mlir_incs
)
message
(
STATUS
"infrt srcs:
\n
${
infrt_src
}
"
)
cc_library
(
infrt SRCS
${
infrt_src
}
DEPS glog boost
${
mlir_libs
}
paddle_framework_proto
)
cc_library
(
infrt SHARED SRCS
${
infrt_src
}
DEPS glog boost
${
mlir_libs
}
paddle_framework_proto
)
cc_library
(
infrt_static SRCS
${
infrt_src
}
DEPS glog boost
${
mlir_libs
}
paddle_framework_proto
)
add_dependencies
(
infrt
${
infrt_mlir_incs
}
)
paddle/infrt/dialect/CMakeLists.txt
浏览文件 @
a3bd6fc0
...
...
@@ -37,25 +37,17 @@ add_dependencies(print-ir pd_ops_inc)
# MLIR opt tests
# %{
set
(
infrt_opt_path
${
CMAKE_BINARY_DIR
}
/infrt/dialect/infrtopt
)
add_test
(
test_infrt_mlir_opt_on_basic
${
infrt_opt_path
}
${
CMAKE_SOURCE_DIR
}
/infrt/dialect/mlir_tests/basic.mlir
)
add_test
(
test_infrt_mlir_opt_on_tensor_shape
${
infrt_opt_path
}
${
CMAKE_SOURCE_DIR
}
/infrt/dialect/mlir_tests/tensor_shape.mlir
)
add_test
(
test_infrt_mlir_opt_on_paddle_ops
${
infrt_opt_path
}
${
CMAKE_SOURCE_DIR
}
/infrt/dialect/mlir_tests/paddle_ops.mlir
)
set
(
infrt_opt_path
${
CMAKE_CURRENT_BINARY_DIR
}
/infrtopt
)
add_test
(
test_infrt_mlir_opt_on_basic
${
infrt_opt_path
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/mlir_tests/basic.mlir
)
add_test
(
test_infrt_mlir_opt_on_tensor_shape
${
infrt_opt_path
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/mlir_tests/tensor_shape.mlir
)
add_test
(
test_infrt_mlir_opt_on_paddle_op
${
infrt_opt_path
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/mlir_tests/paddle_ops.mlir
)
# %}
cc_test_tiny
(
test_infrt_mlir_loader SRCS mlir_loader_test.cc DEPS infrt
${
MLIR_IR_LIBS
}
)
# execute mlir and run FileCheck
infrt_exec_check
(
run_and_check_tensor_type mlir_tests/tensor_type.mlir
)
infrt_exec_check
(
run_and_check_basic mlir_tests/basic.mlir
)
infrt_exec_check
(
run_and_check_benchmark mlir_tests/benchmark.mlir
)
#infrt_exec_check(run_and_check_dense_tensor mlir_tests/dense_tensor.mlir)
add_test
(
test_infrt_mlir_dense_tensor
${
CMAKE_BINARY_DIR
}
/infrt/host_context/infrt-exec
-i
${
CMAKE_CURRENT_SOURCE_DIR
}
/mlir_tests/dense_tensor.mlir
)
infrt_exec_check
(
test_infrt_tensor_type mlir_tests/tensor_type.mlir
)
infrt_exec_check
(
test_infrt__basic mlir_tests/basic.mlir
)
infrt_exec_check
(
test_infrt_benchmark mlir_tests/benchmark.mlir
)
infrt_exec_check
(
test_infrt_mlir_dense_tensor mlir_tests/dense_tensor.mlir
)
paddle/infrt/dialect/mlir_tests/dense_tensor.mlir
浏览文件 @
a3bd6fc0
// CHECK-LABEL: dense_shape0
func @dense_shape0() {
%shape = ts.build_shape [1:i64, 57:i64]
%a = dt.create_uninit_tensor.f32 [12:i64, 23:i64] -> !infrt.tensor<X86, NCHW, F32>
...
...
paddle/scripts/infrt_build.sh
0 → 100644
浏览文件 @
a3bd6fc0
#!/usr/bin/env bash
# Copyright (c) 2021 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.
#=================================================
# Utils
#=================================================
set
-ex
if
[
-z
${
BRANCH
}
]
;
then
BRANCH
=
"develop"
fi
EXIT_CODE
=
0
;
tmp_dir
=
`
mktemp
-d
`
function
init
()
{
RED
=
'\033[0;31m'
BLUE
=
'\033[0;34m'
BOLD
=
'\033[1m'
NONE
=
'\033[0m'
PADDLE_ROOT
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../"
&&
pwd
)
"
export
PADDLE_ROOT
if
[
-z
"
${
SCRIPT_NAME
}
"
]
;
then
SCRIPT_NAME
=
$0
fi
ENABLE_MAKE_CLEAN
=
${
ENABLE_MAKE_CLEAN
:-
ON
}
# NOTE(chenweihang): For easy debugging, CI displays the C++ error stacktrace by default
export
FLAGS_call_stack_level
=
2
# set CI_SKIP_CPP_TEST if only *.py changed
# In order to avoid using in some CI(such as daily performance), the current
# branch must not be `${BRANCH}` which is usually develop.
if
[
${
CI_SKIP_CPP_TEST
:-
ON
}
==
"OFF"
]
;
then
echo
"CI_SKIP_CPP_TEST=OFF"
else
if
[
"
$(
git branch |
grep
"^
\*
"
|
awk
'{print $2}'
)
"
!=
"
${
BRANCH
}
"
]
;
then
git diff
--name-only
${
BRANCH
}
|
grep
-v
"
\.
py$"
||
export
CI_SKIP_CPP_TEST
=
ON
fi
fi
}
function
infrt_gen_and_build
()
{
if
[
"
$1
"
!=
""
]
;
then
parallel_number
=
$1
fi
startTime_s
=
`
date
+%s
`
set
+e
mkdir
-p
${
PADDLE_ROOT
}
/build
cd
${
PADDLE_ROOT
}
/build
rm
-f
infrt_summary.txt
cmake ..
-DWITH_MKL
=
OFF
-DWITH_GPU
=
OFF
-DCMAKE_BUILD_TYPE
=
Release
-DWITH_INFRT
=
ON
-DWITH_TESTING
==
${
WITH_TESTING
:-
ON
}
;
build_error
=
$?
if
[
"
$build_error
"
!=
0
]
;
then
exit
7
;
fi
make
-j
${
parallel_number
}
infrt infrtopt infrt-exec
;
build_error
=
$?
make
-j
${
parallel_number
}
infrt_lib_dist
;
build_error
=
$?
if
[
"
$build_error
"
!=
0
]
;
then
exit
7
;
fi
endTime_s
=
`
date
+%s
`
[
-n
"
$startTime_firstBuild
"
]
&&
startTime_s
=
$startTime_firstBuild
echo
"Build Time:
$[
$endTime_s
-
$startTime_s
]s"
echo
"ipipe_log_param_Infrt_Build_Time:
$[
$endTime_s
-
$startTime_s
]s"
>>
${
PADDLE_ROOT
}
/build/infrt_summary.txt
}
function
test_infrt
()
{
mkdir
-p
${
PADDLE_ROOT
}
/build
cd
${
PADDLE_ROOT
}
/build
if
[
${
WITH_TESTING
:-
ON
}
==
"ON"
]
;
then
cat
<<
EOF
========================================
Running infrt unit tests ...
========================================
EOF
tmpfile_rand
=
`
date
+%s%N
`
tmpfile
=
$tmp_dir
/
$tmpfile_rand
ut_startTime_s
=
`
date
+%s
`
ctest
--output-on-failure
-R
test_infrt
*
|
tee
$tmpfile
ut_endTime_s
=
`
date
+%s
`
echo
"infrt testCase Time:
$[
$ut_endTime_s
-
$ut_startTime_s
]s"
exit_code
=
0
grep
-q
'The following tests FAILED:'
$tmpfile
||
exit_code
=
$?
if
[
$exit_code
-eq
0
]
;
then
exit
8
;
fi
fi
}
function
main
()
{
local
CMD
=
$1
local
parallel_number
=
$2
init
case
$CMD
in
build_and_test
)
infrt_gen_and_build
${
parallel_number
}
test_infrt
;;
*
)
print_usage
exit
1
;;
esac
set
+x
if
[[
-f
${
PADDLE_ROOT
}
/build/infrt_summary.txt
]]
;
then
echo
"=====================build summary======================"
cat
${
PADDLE_ROOT
}
/build/infrt_summary.txt
echo
"========================================================"
fi
echo
"paddle_build script finished as expected"
}
main
$@
rm
-rf
tmp_dir
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录