Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
0ff43268
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看板
未验证
提交
0ff43268
编写于
3月 24, 2020
作者:
H
huzhiqiang
提交者:
GitHub
3月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Python whl] add whl output for x86 python lib (#3211)
上级
cf2d38b0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
117 addition
and
6 deletion
+117
-6
lite/CMakeLists.txt
lite/CMakeLists.txt
+12
-1
lite/api/python/CMakeLists.txt
lite/api/python/CMakeLists.txt
+17
-0
lite/api/python/__init__.py
lite/api/python/__init__.py
+13
-0
lite/api/python/pybind/pybind.cc
lite/api/python/pybind/pybind.cc
+0
-3
lite/api/python/pybind/pybind.h
lite/api/python/pybind/pybind.h
+1
-1
lite/api/python/setup.py.in
lite/api/python/setup.py.in
+72
-0
lite/tools/build.sh
lite/tools/build.sh
+2
-1
未找到文件。
lite/CMakeLists.txt
浏览文件 @
0ff43268
...
@@ -83,7 +83,16 @@ message(STATUS "publish inference lib to ${INFER_LITE_PUBLISH_ROOT}")
...
@@ -83,7 +83,16 @@ message(STATUS "publish inference lib to ${INFER_LITE_PUBLISH_ROOT}")
if
(
LITE_WITH_PYTHON
)
if
(
LITE_WITH_PYTHON
)
add_custom_target
(
publish_inference_python_lib
${
TARGET
}
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/lib"
COMMAND cp
"
${
CMAKE_BINARY_DIR
}
/lite/api/python/pybind/liblite_pybind.so"
"
${
INFER_LITE_PUBLISH_ROOT
}
/python/lib/lite_core.so"
)
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.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"
)
add_custom_target
(
publish_inference_python_installer
${
TARGET
}
COMMAND python setup.py bdist_wheel
WORKING_DIRECTORY
${
INFER_LITE_PUBLISH_ROOT
}
/python/install/
DEPENDS publish_inference_python_lib
)
add_custom_target
(
publish_inference_python_light_demo
${
TARGET
}
add_custom_target
(
publish_inference_python_light_demo
${
TARGET
}
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/demo/python"
COMMAND mkdir -p
"
${
INFER_LITE_PUBLISH_ROOT
}
/demo/python"
COMMAND cp
"
${
CMAKE_SOURCE_DIR
}
/lite/demo/python/mobilenetv1_light_api.py"
"
${
INFER_LITE_PUBLISH_ROOT
}
/demo/python/"
)
COMMAND cp
"
${
CMAKE_SOURCE_DIR
}
/lite/demo/python/mobilenetv1_light_api.py"
"
${
INFER_LITE_PUBLISH_ROOT
}
/demo/python/"
)
...
@@ -95,6 +104,7 @@ if (LITE_WITH_PYTHON)
...
@@ -95,6 +104,7 @@ if (LITE_WITH_PYTHON)
endif
()
endif
()
add_dependencies
(
publish_inference_python_lib lite_pybind
)
add_dependencies
(
publish_inference_python_lib lite_pybind
)
add_dependencies
(
publish_inference publish_inference_python_lib
)
add_dependencies
(
publish_inference publish_inference_python_lib
)
add_dependencies
(
publish_inference publish_inference_python_installer
)
add_dependencies
(
publish_inference publish_inference_python_light_demo
)
add_dependencies
(
publish_inference publish_inference_python_light_demo
)
endif
()
endif
()
...
@@ -212,6 +222,7 @@ if (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND LITE_WITH_ARM)
...
@@ -212,6 +222,7 @@ if (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND LITE_WITH_ARM)
add_dependencies
(
publish_inference tiny_publish_cxx_lib
)
add_dependencies
(
publish_inference tiny_publish_cxx_lib
)
if
(
NOT
"
${
CMAKE_BUILD_TYPE
}
"
STREQUAL
"Debug"
)
if
(
NOT
"
${
CMAKE_BUILD_TYPE
}
"
STREQUAL
"Debug"
)
add_custom_command
(
TARGET tiny_publish_cxx_lib POST_BUILD
add_custom_command
(
TARGET tiny_publish_cxx_lib POST_BUILD
COMMAND
${
CMAKE_STRIP
}
"-s"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib/libpaddle_api_light_bundled.a
COMMAND
${
CMAKE_STRIP
}
"-s"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib/libpaddle_light_api_shared.so
)
COMMAND
${
CMAKE_STRIP
}
"-s"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib/libpaddle_light_api_shared.so
)
endif
()
endif
()
endif
()
endif
()
...
...
lite/api/python/CMakeLists.txt
浏览文件 @
0ff43268
...
@@ -2,6 +2,23 @@ if (NOT LITE_WITH_PYTHON)
...
@@ -2,6 +2,23 @@ if (NOT LITE_WITH_PYTHON)
return
()
return
()
endif
()
endif
()
# to create setup.py for packeting whl for Paddle-Lite and opt
execute_process
(
COMMAND git describe --tags --exact-match
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
OUTPUT_VARIABLE PADDLE_LITE_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process
(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
OUTPUT_VARIABLE PADDLE_LITE_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/setup.py.in
${
CMAKE_CURRENT_BINARY_DIR
}
/setup.py
)
add_subdirectory
(
pybind
)
add_subdirectory
(
pybind
)
#add_subdirectory(interface)
#add_subdirectory(interface)
lite/api/python/__init__.py
0 → 100644
浏览文件 @
0ff43268
# 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.
lite/api/python/pybind/pybind.cc
浏览文件 @
0ff43268
...
@@ -26,13 +26,10 @@
...
@@ -26,13 +26,10 @@
#ifndef LITE_ON_TINY_PUBLISH
#ifndef LITE_ON_TINY_PUBLISH
#include "lite/api/cxx_api.h"
#include "lite/api/cxx_api.h"
#include "lite/api/paddle_use_passes.h"
#endif
#endif
#include "lite/api/light_api.h"
#include "lite/api/light_api.h"
#include "lite/api/paddle_api.h"
#include "lite/api/paddle_api.h"
#include "lite/api/paddle_use_kernels.h"
#include "lite/api/paddle_use_ops.h"
#include "lite/core/tensor.h"
#include "lite/core/tensor.h"
namespace
py
=
pybind11
;
namespace
py
=
pybind11
;
...
...
lite/api/python/pybind/pybind.h
浏览文件 @
0ff43268
...
@@ -23,7 +23,7 @@ namespace pybind {
...
@@ -23,7 +23,7 @@ namespace pybind {
void
BindLiteApi
(
pybind11
::
module
*
m
);
void
BindLiteApi
(
pybind11
::
module
*
m
);
PYBIND11_MODULE
(
lite
_core
,
m
)
{
PYBIND11_MODULE
(
lite
,
m
)
{
m
.
doc
()
=
"C++ core of Paddle-Lite"
;
m
.
doc
()
=
"C++ core of Paddle-Lite"
;
BindLiteApi
(
&
m
);
BindLiteApi
(
&
m
);
...
...
lite/api/python/setup.py.in
0 → 100644
浏览文件 @
0ff43268
# 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_intel.so', 'libiomp5.so']
# link lite.so to paddlelite.libs
COMMAND = "patchelf --set-rpath '$ORIGIN/../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/tools/build.sh
浏览文件 @
0ff43268
...
@@ -356,10 +356,11 @@ function make_x86 {
...
@@ -356,10 +356,11 @@ function make_x86 {
-DWITH_LITE
=
ON
\
-DWITH_LITE
=
ON
\
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK
=
OFF
\
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK
=
OFF
\
-DLITE_WITH_ARM
=
OFF
\
-DLITE_WITH_ARM
=
OFF
\
-DLITE_WITH_PYTHON
=
$BUILD_PYTHON
\
-DWITH_GPU
=
OFF
\
-DWITH_GPU
=
OFF
\
-DLITE_BUILD_EXTRA
=
ON
\
-DLITE_BUILD_EXTRA
=
ON
\
-DLITE_WITH_XPU
=
$BUID_XPU
\
-DLITE_WITH_XPU
=
$BUID_XPU
\
-DXPU_SDK_ROOT
=
$XPU_SDK_ROOT
\
-DXPU_SDK_ROOT
=
$XPU_SDK_ROOT
make publish_inference
-j
$NUM_PROC
make publish_inference
-j
$NUM_PROC
cd
-
cd
-
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录