!35170 [MS][LITE] fix python api codex

Merge pull request !35170 from luoyuan/fix-codex-0530
This commit is contained in:
i-robot 2022-05-31 09:12:57 +00:00 committed by Gitee
commit bc52caaa1d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 13 additions and 3 deletions

View File

@ -167,10 +167,10 @@ build_lite_jni_and_jar() {
}
build_python_wheel_package() {
local python_version=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}'`
local python_version=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}'` || true
if [[ "${python_version}" == "3" ]]; then
cd ${BASEPATH}/mindspore/lite/build/
local lite_wrapper_so=`ls python/*.so`
local lite_wrapper_so=`ls python/*.so` || true
if [ ! -f "${lite_wrapper_so}" ]; then
return 0
fi
@ -194,7 +194,7 @@ build_python_wheel_package() {
export TOP_DIR=${BASEPATH}
cd package
python setup.py bdist_wheel
local minor_version=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}'`
local minor_version=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}'` || true
local py_tags="cp${python_version}${minor_version}-cp${python_version}${minor_version}"
if [[ "${minor_version}" == "7" ]]; then
py_tags="cp37-cp37m"

View File

@ -17,12 +17,19 @@ if(Python3_FOUND)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../core/)
file(GLOB_RECURSE PY_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
if(NOT MSLITE_ENABLE_CONVERTER)
file(GLOB_RECURSE CONVERTER_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "converter_pybind.cc")
list(REMOVE_ITEM PY_SRC_LIST ${CONVERTER_SRC_FILES})
endif()
pybind11_add_module(_c_lite_wrapper NO_EXTRAS ${PY_SRC_LIST})
target_link_libraries(_c_lite_wrapper PRIVATE -Wl,--whole-archive mindspore-lite_static -Wl,--no-whole-archive)
if(MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_RUNTIME_GLOG)
target_link_libraries(_c_lite_wrapper PRIVATE mindspore::glog)
endif()
if(MSLITE_ENABLE_CONVERTER)
target_link_libraries(_c_lite_wrapper PRIVATE mindspore_converter)
endif()
else()
message(WARNING "NumPy not found, so Python API will not be compiled.")
endif()

View File

@ -27,6 +27,9 @@ __all__ = ['ModelType', 'Model', 'RunnerConfig', 'ModelParallelRunner']
class ModelType(Enum):
"""
The MoedelType is used to define the model type.
"""
MINDIR = 0
MINDIR_LITE = 4