Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
10317f38
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
10317f38
编写于
4月 14, 2020
作者:
H
huzhiqiang
提交者:
GitHub
4月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[mac python] mac env supports outputs of python lib and installer (#3394)
上级
9163fcfb
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
167 addition
and
55 deletion
+167
-55
CMakeLists.txt
CMakeLists.txt
+3
-1
cmake/configure.cmake
cmake/configure.cmake
+1
-1
cmake/external/mklml.cmake
cmake/external/mklml.cmake
+9
-6
cmake/external/python.cmake
cmake/external/python.cmake
+2
-2
cmake/generic.cmake
cmake/generic.cmake
+1
-1
lite/CMakeLists.txt
lite/CMakeLists.txt
+54
-26
lite/api/CMakeLists.txt
lite/api/CMakeLists.txt
+8
-6
lite/api/cxx_api_impl.cc
lite/api/cxx_api_impl.cc
+2
-5
lite/api/python/CMakeLists.txt
lite/api/python/CMakeLists.txt
+7
-3
lite/api/python/setup_mac.py.in
lite/api/python/setup_mac.py.in
+73
-0
lite/backends/x86/CMakeLists.txt
lite/backends/x86/CMakeLists.txt
+1
-1
lite/backends/x86/dynamic_loader.cc
lite/backends/x86/dynamic_loader.cc
+1
-1
lite/kernels/x86/CMakeLists.txt
lite/kernels/x86/CMakeLists.txt
+5
-1
lite/tools/build.sh
lite/tools/build.sh
+0
-1
未找到文件。
CMakeLists.txt
浏览文件 @
10317f38
...
...
@@ -209,7 +209,9 @@ include(generic) # simplify cmake module
include
(
ccache
)
# set ccache for compilation
include
(
util
)
# set unittest and link libs
include
(
version
)
# set PADDLE_VERSION
include
(
flags
)
if
(
NOT APPLE
)
include
(
flags
)
endif
()
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O3 -g -DNDEBUG"
)
set
(
CMAKE_C_FLAGS_RELWITHDEBINFO
"-O3 -g -DNDEBUG"
)
...
...
cmake/configure.cmake
浏览文件 @
10317f38
...
...
@@ -70,7 +70,7 @@ endif()
if
(
WITH_MKLML AND MKLML_IOMP_LIB
)
message
(
STATUS
"Enable Intel OpenMP with
${
MKLML_IOMP_LIB
}
"
)
if
(
WIN32
)
if
(
WIN32
OR APPLE
)
# openmp not support well for now on windows
set
(
OPENMP_FLAGS
""
)
else
(
WIN32
)
...
...
cmake/external/mklml.cmake
浏览文件 @
10317f38
...
...
@@ -16,12 +16,6 @@ IF(NOT ${WITH_MKLML})
return
()
ENDIF
(
NOT
${
WITH_MKLML
}
)
IF
(
APPLE
)
MESSAGE
(
WARNING
"Mac is not supported with MKLML in Paddle yet. Force WITH_MKLML=OFF."
)
SET
(
WITH_MKLML OFF CACHE STRING
"Disable MKLML package in MacOS"
FORCE
)
return
()
ENDIF
()
INCLUDE
(
ExternalProject
)
SET
(
MKLML_DST_DIR
"mklml"
)
SET
(
MKLML_INSTALL_ROOT
"
${
THIRD_PARTY_PATH
}
/install"
)
...
...
@@ -39,6 +33,15 @@ IF(WIN32)
SET
(
MKLML_IOMP_LIB
${
MKLML_LIB_DIR
}
/libiomp5md.lib
)
SET
(
MKLML_SHARED_LIB
${
MKLML_LIB_DIR
}
/mklml.dll
)
SET
(
MKLML_SHARED_IOMP_LIB
${
MKLML_LIB_DIR
}
/libiomp5md.dll
)
ELSEIF
(
APPLE
)
#TODO(intel-huying):
# Now enable Erf function in mklml library temporarily, it will be updated as offical version later.
SET
(
MKLML_VER
"mklml_mac_2019.0.5.20190502"
CACHE STRING
""
FORCE
)
SET
(
MKLML_URL
"https://paddlelite-data.bj.bcebos.com/third_party_libs/
${
MKLML_VER
}
.tgz"
CACHE STRING
""
FORCE
)
SET
(
MKLML_LIB
${
MKLML_LIB_DIR
}
/libmklml.dylib
)
SET
(
MKLML_IOMP_LIB
${
MKLML_LIB_DIR
}
/libiomp5.dylib
)
SET
(
MKLML_SHARED_LIB
${
MKLML_LIB_DIR
}
/libmklml.dylib
)
SET
(
MKLML_SHARED_IOMP_LIB
${
MKLML_LIB_DIR
}
/libiomp5.dylib
)
ELSE
()
#TODO(intel-huying):
# Now enable Erf function in mklml library temporarily, it will be updated as offical version later.
...
...
cmake/external/python.cmake
浏览文件 @
10317f38
...
...
@@ -70,10 +70,10 @@ SET_PROPERTY(TARGET python PROPERTY IMPORTED_LOCATION ${PYTHON_LIBRARIES})
SET
(
py_env
""
)
IF
(
PYTHONINTERP_FOUND
)
find_python_module
(
pip REQUIRED
)
find_python_module
(
numpy REQUIRED
)
#
find_python_module(numpy REQUIRED)
#find_python_module(wheel REQUIRED)
#find_python_module(google.protobuf REQUIRED)
FIND_PACKAGE
(
NumPy REQUIRED
)
#
FIND_PACKAGE(NumPy REQUIRED)
#IF(${PY_GOOGLE.PROTOBUF_VERSION} AND ${PY_GOOGLE.PROTOBUF_VERSION} VERSION_LESS "3.0.0")
# MESSAGE(FATAL_ERROR "Found Python Protobuf ${PY_GOOGLE.PROTOBUF_VERSION} < 3.0.0, "
# "please use pip to upgrade protobuf. pip install -U protobuf")
...
...
cmake/generic.cmake
浏览文件 @
10317f38
...
...
@@ -276,7 +276,7 @@ function(cc_library TARGET_NAME)
add_dependencies
(
${
TARGET_NAME
}
mklml
)
if
(
WIN32
)
target_link_libraries
(
${
TARGET_NAME
}
${
MKLML_IOMP_LIB
}
)
else
(
WIN32
)
else
if
(
NOT APPLE
)
target_link_libraries
(
${
TARGET_NAME
}
"-L
${
MKLML_LIB_DIR
}
-liomp5 -Wl,--as-needed"
)
endif
(
WIN32
)
endif
()
...
...
lite/CMakeLists.txt
浏览文件 @
10317f38
...
...
@@ -83,6 +83,16 @@ message(STATUS "publish inference lib to ${INFER_LITE_PUBLISH_ROOT}")
# add python lib
if
(
LITE_WITH_PYTHON
)
if
(
APPLE
)
add_custom_target
(
publish_inference_python_lib
${
TARGET
}
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/lib"
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/libs"
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/lite"
COMMAND cp
"
${
CMAKE_BINARY_DIR
}
/lite/api/python/setup.py"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/"
COMMAND cp
"
${
CMAKE_SOURCE_DIR
}
/lite/api/python/__init__.py"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/lite"
COMMAND cp
"
${
CMAKE_BINARY_DIR
}
/lite/api/python/pybind/liblite_pybind.dylib"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/lite/lite.so"
COMMAND cp
"
${
CMAKE_BINARY_DIR
}
/lite/api/python/pybind/liblite_pybind.dylib"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/lib/lite.so"
)
else
()
add_custom_target
(
publish_inference_python_lib
${
TARGET
}
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/lib"
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/libs"
...
...
@@ -91,6 +101,7 @@ if (LITE_WITH_PYTHON)
COMMAND cp
"
${
CMAKE_SOURCE_DIR
}
/lite/api/python/__init__.py"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/lite"
COMMAND cp
"
${
CMAKE_BINARY_DIR
}
/lite/api/python/pybind/liblite_pybind.so"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/lite/lite.so"
COMMAND cp
"
${
CMAKE_BINARY_DIR
}
/lite/api/python/pybind/liblite_pybind.so"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/lib/lite.so"
)
endif
()
add_custom_target
(
publish_inference_python_installer
${
TARGET
}
COMMAND
${
PYTHON_EXECUTABLE
}
setup.py bdist_wheel
WORKING_DIRECTORY
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/
...
...
@@ -111,6 +122,22 @@ if (LITE_WITH_PYTHON)
endif
()
if
(
LITE_WITH_CUDA OR LITE_WITH_X86
)
if
(
APPLE
)
add_custom_target
(
publish_inference_cxx_lib
${
TARGET
}
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib"
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/bin"
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/include"
COMMAND cp
"
${
CMAKE_SOURCE_DIR
}
/lite/api/paddle_*.h"
"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/include"
COMMAND cp
"
${
CMAKE_BINARY_DIR
}
/lite/api/*.dylib"
"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib"
)
add_custom_target
(
publish_inference_third_party
${
TARGET
}
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/third_party"
COMMAND cp -r
"
${
CMAKE_BINARY_DIR
}
/third_party/install/*"
"
${
INFER_LITE_PUBLISH_ROOT
}
/third_party"
)
add_dependencies
(
publish_inference_cxx_lib paddle_full_api_shared
)
add_dependencies
(
publish_inference_cxx_lib paddle_light_api_shared
)
add_dependencies
(
publish_inference publish_inference_cxx_lib
)
add_dependencies
(
publish_inference publish_inference_third_party
)
else
()
add_custom_target
(
publish_inference_cxx_lib
${
TARGET
}
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib"
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/bin"
...
...
@@ -129,6 +156,7 @@ if (LITE_WITH_CUDA OR LITE_WITH_X86)
add_dependencies
(
publish_inference_cxx_lib paddle_light_api_shared
)
add_dependencies
(
publish_inference publish_inference_cxx_lib
)
add_dependencies
(
publish_inference publish_inference_third_party
)
endif
()
endif
()
if
(
LITE_WITH_X86
)
...
...
lite/api/CMakeLists.txt
浏览文件 @
10317f38
...
...
@@ -37,12 +37,14 @@ if ((NOT LITE_ON_TINY_PUBLISH) AND (LITE_WITH_CUDA OR LITE_WITH_X86 OR LITE_WITH
)
add_dependencies
(
paddle_light_api_shared op_list_h kernel_list_h
)
target_link_libraries
(
paddle_light_api_shared
${
light_lib_DEPS
}
${
arm_kernels
}
${
npu_kernels
}
)
if
(
NOT APPLE
)
set
(
LINK_MAP_FILE
"
${
PADDLE_SOURCE_DIR
}
/lite/core/lite.map"
)
set
(
LINK_FLAGS
"-Wl,--version-script
${
LINK_MAP_FILE
}
"
)
add_custom_command
(
OUTPUT
${
LINK_MAP_FILE
}
COMMAND ...
)
add_custom_target
(
custom_linker_map DEPENDS
${
LINK_MAP_FILE
}
)
set_target_properties
(
paddle_full_api_shared PROPERTIES LINK_FLAGS
${
LINK_FLAGS
}
)
add_dependencies
(
paddle_full_api_shared custom_linker_map
)
endif
()
else
()
if
((
ARM_TARGET_OS STREQUAL
"android"
)
OR
(
ARM_TARGET_OS STREQUAL
"armlinux"
))
add_library
(
paddle_light_api_shared SHARED
""
)
...
...
lite/api/cxx_api_impl.cc
浏览文件 @
10317f38
...
...
@@ -19,13 +19,11 @@
#include "lite/api/paddle_api.h"
#include "lite/core/device_info.h"
#include "lite/core/version.h"
#if (defined LITE_WITH_X86) && (defined PADDLE_WITH_MKLML) && \
!(defined LITE_ON_MODEL_OPTIMIZE_TOOL)
!(defined LITE_ON_MODEL_OPTIMIZE_TOOL)
&& !defined(__APPLE__)
#include <omp.h>
#include "lite/backends/x86/mklml.h"
#endif
namespace
paddle
{
namespace
lite
{
...
...
@@ -67,9 +65,8 @@ void CxxPaddleApiImpl::Init(const lite_api::CxxConfig &config) {
raw_predictor_
.
Build
(
config
,
places
,
passes
);
mode_
=
config
.
power_mode
();
threads_
=
config
.
threads
();
#if (defined LITE_WITH_X86) && (defined PADDLE_WITH_MKLML) && \
!(defined LITE_ON_MODEL_OPTIMIZE_TOOL)
!(defined LITE_ON_MODEL_OPTIMIZE_TOOL)
&& !defined(__APPLE__)
int
num_threads
=
config
.
x86_math_library_num_threads
();
int
real_num_threads
=
num_threads
>
1
?
num_threads
:
1
;
paddle
::
lite
::
x86
::
MKL_Set_Num_Threads
(
real_num_threads
);
...
...
lite/api/python/CMakeLists.txt
浏览文件 @
10317f38
...
...
@@ -17,8 +17,12 @@ execute_process(
OUTPUT_VARIABLE PADDLE_LITE_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/setup.py.in
if
(
APPLE
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/setup_mac.py.in
${
CMAKE_CURRENT_BINARY_DIR
}
/setup.py
)
else
()
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/setup.py.in
${
CMAKE_CURRENT_BINARY_DIR
}
/setup.py
)
endif
()
add_subdirectory
(
pybind
)
#add_subdirectory(interface)
lite/api/python/setup_mac.py.in
0 → 100644
浏览文件 @
10317f38
# Copyright (c) 2019 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.
# module of pack whl installer for Paddle-lite
import shutil
import os
from setuptools import setup, Distribution
class BinaryDistribution(Distribution):
'binary distribution'
def has_ext_modules(foo):
return True
# get paddle-lite version, if it's not based on a release tag, we use commit id instead
PADDLELITE_COMMITE = "@PADDLE_LITE_COMMIT@"
PADDLELITE_TAG = "@PADDLE_LITE_TAG@"
if PADDLELITE_TAG == "":
PADDLELITE_VERSION = PADDLELITE_COMMITE
else:
PADDLELITE_VERSION = PADDLELITE_TAG
# core lib of paddlelite is stored as lite.so
LITE_PATH = '${PADDLE_BINARY_DIR}/inference_lite_lib/python/install/lite'
PACKAGE_DATA = {'paddlelite': ['lite.so']}
# put all thirdparty libraries in paddlelite.libs
PACKAGE_DATA['paddlelite.libs'] = []
LIB_PATH = '${PADDLE_BINARY_DIR}/inference_lite_lib/python/install/libs'
if '${WITH_MKL}' == 'ON':
shutil.copy('${MKLML_SHARED_IOMP_LIB}', LIB_PATH)
shutil.copy('${MKLML_SHARED_LIB}', LIB_PATH)
PACKAGE_DATA['paddlelite.libs'] += ['libmklml.dylib', 'libiomp5.dylib']
# link lite.so to paddlelite.libs
COMMAND = "install_name_tool -id \"@loader_path/../libs/\" ${PADDLE_BINARY_DIR}\
/inference_lite_lib/python/install/lite/lite.so"
if os.system(COMMAND) != 0:
raise Exception("patch third_party libs failed, command: %s" % COMMAND)
# remove unused paddle/libs/__init__.py
if os.path.isfile(LIB_PATH+'/__init__.py'):
os.remove(LIB_PATH+'/__init__.py')
# set dir path of each package
PACKAGE_DIR = {
# The paddle.fluid.proto will be generated while compiling.
# So that package points to other directory.
'paddlelite.libs': LIB_PATH,
'paddlelite': LITE_PATH
}
setup(
name='paddlelite',
version=PADDLELITE_VERSION,
description='Paddle-Lite Library',
packages=['paddlelite', 'paddlelite.libs'],
package_dir=PACKAGE_DIR,
package_data=PACKAGE_DATA,
distclass=BinaryDistribution
)
lite/backends/x86/CMakeLists.txt
浏览文件 @
10317f38
...
...
@@ -10,7 +10,7 @@ if (LITE_ON_MODEL_OPTIMIZE_TOOL)
endif
(
LITE_ON_MODEL_OPTIMIZE_TOOL
)
lite_cc_library
(
dynamic_loader SRCS dynamic_loader.cc DEPS glog gflags
)
lite_cc_library
(
dynload_mklml SRCS mklml.cc DEPS dynamic_loader mklml
)
lite_cc_library
(
x86_cpu_info SRCS cpu_info.cc
DEPS xbyak
)
lite_cc_library
(
x86_cpu_info SRCS cpu_info.cc
)
add_subdirectory
(
jit
)
add_subdirectory
(
math
)
lite/backends/x86/dynamic_loader.cc
浏览文件 @
10317f38
...
...
@@ -262,7 +262,7 @@ void* GetTensorRtDsoHandle() {
void
*
GetMKLMLDsoHandle
()
{
#if defined(__APPLE__) || defined(__OSX__)
return
GetDsoHandleFromSearchPath
(
mklml_dir
,
"libmklml
_intel
.dylib"
);
return
GetDsoHandleFromSearchPath
(
mklml_dir
,
"libmklml.dylib"
);
#elif defined(_WIN32)
return
GetDsoHandleFromSearchPath
(
mklml_dir
,
"mklml.dll"
);
#else
...
...
lite/kernels/x86/CMakeLists.txt
浏览文件 @
10317f38
...
...
@@ -24,7 +24,11 @@ add_kernel(stack_compute_x86 X86 basic SRCS stack_compute.cc DEPS ${lite_kernel_
add_kernel
(
dropout_compute_x86 X86 basic SRCS dropout_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
transpose_compute_x86 X86 basic SRCS transpose_compute.cc DEPS
${
lite_kernel_deps
}
math_function
)
add_kernel
(
layer_norm_compute_x86 X86 basic SRCS layer_norm_compute.cc DEPS
${
lite_kernel_deps
}
jit_kernel_helper
)
add_kernel
(
fc_compute_x86 X86 basic SRCS fc_compute.cc DEPS
${
lite_kernel_deps
}
jit_kernel_helper
)
# todo: fc x86 kernel can not compile successfully on mac because openmp is not supported on mac clang,
# this problem should be fixed later to support fc x86 kernel on mac. @DannyIsFunny
if
(
NOT APPLE
)
add_kernel
(
fc_compute_x86 X86 basic SRCS fc_compute.cc DEPS
${
lite_kernel_deps
}
jit_kernel_helper
)
endif
()
# lite_cc_library(batch_norm_compute_x86 SRCS batch_norm_compute.cc DEPS ${lite_kernel_deps})
# lite_cc_library(uniform_random_compute_x86 SRCS uniform_random_compute.cc DEPS ${lite_kernel_deps} )
add_kernel
(
gru_compute_x86 X86 basic SRCS gru_compute.cc DEPS
${
lite_kernel_deps
}
blas math_function sequence2batch gru_compute
)
...
...
lite/tools/build.sh
浏览文件 @
10317f38
...
...
@@ -365,7 +365,6 @@ function make_x86 {
-DWITH_LITE
=
ON
\
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK
=
OFF
\
-DLITE_WITH_ARM
=
OFF
\
-DLITE_WITH_PYTHON
=
$BUILD_PYTHON
\
-DWITH_GPU
=
OFF
\
-DLITE_WITH_PYTHON
=
${
BUILD_PYTHON
}
\
-DLITE_BUILD_EXTRA
=
ON
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录