This commit is contained in:
yefeng 2021-06-05 10:17:17 +08:00
parent 1198e64c05
commit 30f189e999
8 changed files with 69 additions and 52 deletions

View File

@ -572,7 +572,7 @@ build_lite()
if [ "$(uname)" == "Darwin" ]; then
cmake -DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake -DARCHS="arm64" -DENABLE_BITCODE=0 \
-DCMAKE_BUILD_TYPE="Release" -DBUILD_MINDDATA="" -DPLATFORM_ARM64="on" -DENABLE_NEON="on" -DENABLE_FP16="on" \
-DMSLITE_ENABLE_TRAIN="off" -DENABLE_MINDRT="off" -DMSLITE_GPU_BACKEND="off" -DMSLITE_ENABLE_NPU="off" \
-DMSLITE_ENABLE_TRAIN="off" -DENABLE_MINDRT="on" -DMSLITE_GPU_BACKEND="off" -DMSLITE_ENABLE_NPU="off" \
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp -G Xcode ..
else
checkndk
@ -586,9 +586,9 @@ build_lite()
fi
elif [[ "${local_lite_platform}" == "arm32" ]]; then
if [ "$(uname)" == "Darwin" ]; then
cmake -DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake -DARCHS="armv7;armv7s" -DENABLE_BITCODE=0 \
-DCMAKE_BUILD_TYPE="Release" -DBUILD_MINDDATA="" -DPLATFORM_ARM32="on" -DENABLE_NEON="on" \
-DMSLITE_ENABLE_TRAIN="off" -DENABLE_MINDRT="off" \
cmake -DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake -DARCHS="armv7;armv7s" -DENABLE_BITCODE=0 \
-DCMAKE_BUILD_TYPE="Release" -DBUILD_MINDDATA="" -DPLATFORM_ARM32="on" -DENABLE_NEON="on" \
-DMSLITE_ENABLE_TRAIN="off" -DENABLE_MINDRT="on" -DMSLITE_GPU_BACKEND="off" -DMSLITE_ENABLE_NPU="off" \
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp -G Xcode ..
else
checkndk
@ -606,7 +606,7 @@ build_lite()
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DENABLE_VERBOSE=${ENABLE_VERBOSE} "${BASEPATH}/mindspore/lite"
fi
if [ "$(uname)" == "Darwin" ]; then
xcodebuild ONLY_ACTIVE_ARCH=NO -configuration Release -scheme mindspore_lite -target mindspore_lite -sdk iphoneos -quiet
xcodebuild ONLY_ACTIVE_ARCH=NO -configuration Release -scheme mindspore-lite_static -target mindspore-lite_static -sdk iphoneos -quiet
else
make -j$THREAD_NUM && make install && make package
if [[ "${local_lite_platform}" == "x86_64" ]]; then
@ -625,12 +625,12 @@ build_lite()
else
if [ "$(uname)" == "Darwin" ]; then
mkdir -p ${BASEPATH}/output
cp -r ${BASEPATH}/mindspore/lite/build/src/Release-iphoneos/mindspore_lite.framework ${BASEPATH}/output/mindspore_lite.framework
cp -r ${BASEPATH}/mindspore/lite/build/src/Release-iphoneos/mindspore-lite.framework ${BASEPATH}/output/mindspore-lite.framework
cd ${BASEPATH}/output
tar -zcvf mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz mindspore_lite.framework/
sha256sum mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz > \
mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz.sha256
rm -r mindspore_lite.framework
tar -zcvf mindspore-lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz mindspore-lite.framework/
sha256sum mindspore-lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz > \
mindspore-lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz.sha256
rm -r mindspore-lite.framework
else
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/output/
fi

View File

@ -114,14 +114,26 @@ void ActorMgr::Finalize() {
}
ActorBase *ActorMgr::GetActor(const AID &id) {
#ifndef MS_COMPILE_IOS
actorsMutex.lock_shared();
#else
actorsMutex.lock();
#endif
const auto &actorIt = actors.find(id.Name());
if (actorIt != actors.end()) {
auto &result = actorIt->second;
#ifndef MS_COMPILE_IOS
actorsMutex.unlock_shared();
#else
actorsMutex.unlock();
#endif
return result.get();
} else {
#ifndef MS_COMPILE_IOS
actorsMutex.unlock_shared();
#else
actorsMutex.unlock();
#endif
MS_LOG(DEBUG) << "can't find ACTOR with name=" << id.Name().c_str();
return nullptr;
}

View File

@ -22,8 +22,9 @@
#include <map>
#include <memory>
#include <string>
#ifndef MS_COMPILE_IOS
#include <shared_mutex>
#endif
#include "actor/actor.h"
#include "thread/inter_threadpool.h"
@ -83,8 +84,11 @@ class ActorMgr {
}
// Map of all local spawned and running processes.
std::map<std::string, ActorReference> actors;
#ifndef MS_COMPILE_IOS
std::shared_mutex actorsMutex;
#else
std::mutex actorsMutex;
#endif
std::map<std::string, std::string> procotols;
std::set<std::string> urls;
std::string delegate;

View File

@ -157,7 +157,29 @@ add_dependencies(lite_src_mid fbs_src)
add_library(mindspore-lite SHARED $<TARGET_OBJECTS:lite_src_mid>)
set_target_properties(mindspore-lite PROPERTIES CLEAN_DIRECT_OUTPUT 1)
add_library(mindspore-lite_static STATIC $<TARGET_OBJECTS:lite_src_mid>)
if(DEFINED ARCHS)
set(MINDSPORE_LITE_PUB_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/../include/context.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/errorcode.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/lite_session.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/lite_types.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/lite_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/model.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/ms_tensor.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/version.h
)
set(MINDSPORE_LITE_PUB_HDRS_IR_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/dtype/type_id.h
)
add_library(mindspore-lite_static STATIC
${LITE_SRC}
${MINDSPORE_LITE_PUB_HDRS}
${MINDSPORE_LITE_PUB_HDRS_IR_HDRS}
)
add_dependencies(mindspore-lite_static fbs_inner_src)
else()
add_library(mindspore-lite_static STATIC $<TARGET_OBJECTS:lite_src_mid>)
endif()
set_target_properties(mindspore-lite_static PROPERTIES OUTPUT_NAME "mindspore-lite")
set_target_properties(mindspore-lite_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
@ -224,44 +246,9 @@ if(PLATFORM_ARM)
endif()
if(DEFINED ARCHS)
set(MINDSPORE_LITE_PUB_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/../include/context.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/errorcode.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/lite_session.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/lite_types.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/lite_utils.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/model.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/ms_tensor.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/version.h
)
set(MINDSPORE_LITE_PUB_HDRS_IR_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/dtype/type_id.h
)
add_library(mindspore_lite STATIC
${MINDSPORE_LITE_PUB_HDRS}
${MINDSPORE_LITE_PUB_HDRS_IR_HDRS}
)
add_dependencies(mindspore_lite fbs_src)
set_target_properties(mindspore_lite PROPERTIES OUTPUT_NAME "mindspore_lite")
set_target_properties(mindspore_lite PROPERTIES CLEAN_DIRECT_OUTPUT 1)
target_link_libraries(mindspore_lite lite_src_mid cpu_kernel_mid nnacl_mid cpu_ops_mid)
target_link_libraries(mindspore_lite log)
if(ENABLE_MINDRT)
target_link_libraries(mindspore_lite mindrt_mid)
endif()
if(PLATFORM_ARM)
if(PLATFORM_ARM64)
target_link_libraries(mindspore_lite cpu_opt_kernel_mid nnacl_optimize_mid)
endif()
if(ENABLE_FP16)
target_link_libraries(mindspore_lite cpu_fp16_kernel_mid nnacl_fp16_mid)
endif()
endif()
set_target_properties(mindspore_lite PROPERTIES FRAMEWORK TRUE)
set_target_properties(mindspore_lite PROPERTIES
OUTPUT_NAME "mindspore_lite"
set_target_properties(mindspore-lite_static PROPERTIES FRAMEWORK TRUE)
set_target_properties(mindspore-lite_static PROPERTIES
OUTPUT_NAME "mindspore-lite"
FRAMEWORK_VERSION C
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
XCODE_ATTRIBUTE_INSTALL_PAYH "@rpath"
@ -272,7 +259,7 @@ if(DEFINED ARCHS)
FOREACH(HDR ${MINDSPORE_LITE_PUB_HDRS_IR_HDRS})
SET_SOURCE_FILES_PROPERTIES(${HDR} PROPERTIES MACOSX_PACKAGE_LOCATION Headers/include/ir/dtype/)
ENDFOREACH()
target_link_libraries(mindspore_lite)
target_link_libraries(mindspore-lite_static)
endif()
if(NOT WIN32)

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
#ifdef ENABLE_ARM
#ifndef MS_COMPILE_IOS
#include "src/cpu_info.h"
#include <sys/auxv.h>
#include <asm/hwcap.h>
@ -144,3 +145,4 @@ bool CpuInfo::ArmIsSupportFp16() {
}
} // namespace mindspore::lite
#endif
#endif

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
#ifdef ENABLE_ARM
#ifndef MS_COMPILE_IOS
#include <string>
#ifndef MINDSPORE_LITE_SRC_CPU_INFO_H
#define MINDSPORE_LITE_SRC_CPU_INFO_H
@ -48,3 +49,4 @@ class CpuInfo {
} // namespace mindspore::lite
#endif // MINDSPORE_LITE_SRC_CPU_INFO_H
#endif
#endif

View File

@ -34,9 +34,11 @@ InnerContext::InnerContext(const Context *context) {
this->device_list_.push_back(device_ctx);
}
#ifdef ENABLE_ARM
#ifndef MS_COMPILE_IOS
cpu_info_ = new CpuInfo;
fp16_flag_ = cpu_info_->ArmIsSupportFp16();
#endif
#endif
}
#if SUPPORT_NPU
@ -60,9 +62,11 @@ InnerContext::InnerContext(const Context *context, NPUManager *npu_manager) {
}
this->npu_manager_ = npu_manager;
#ifdef ENABLE_ARM
#ifndef MS_COMPILE_IOS
cpu_info_ = new CpuInfo;
fp16_flag_ = cpu_info_->ArmIsSupportFp16();
#endif
#endif
}
#endif
@ -120,8 +124,10 @@ InnerContext::~InnerContext() {
this->thread_pool_ = nullptr;
}
#ifdef ENABLE_ARM
#ifndef MS_COMPILE_IOS
delete cpu_info_;
#endif
#endif
}
int InnerContext::IsValid() const {

View File

@ -83,12 +83,16 @@ struct InnerContext : public Context {
bool fp16_flag_ = false;
#ifdef ENABLE_ARM
#ifndef MS_COMPILE_IOS
CpuInfo *cpu_info_ = nullptr;
#endif
#endif
#if SUPPORT_NPU
#ifndef MS_COMPILE_IOS
NPUManager *npu_manager_ = nullptr;
#endif
#endif
};
} // namespace mindspore::lite