online compile

This commit is contained in:
zhengyuanhua 2022-03-14 19:40:21 +08:00
parent 95e5475f58
commit 84e98cdaaf
25 changed files with 124 additions and 28 deletions

View File

@ -97,6 +97,14 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
add_subdirectory(mindspore/ccsrc)
add_subdirectory(mindspore/core)
if(DEFINED ENV{ENABLE_CLOUD_AND_LITE})
set(ENABLE_CLOUD_AND_LITE $ENV{ENABLE_CLOUD_AND_LITE})
endif()
if(ENABLE_CLOUD_AND_LITE)
add_subdirectory(mindspore/lite)
endif()
if(ENABLE_TESTCASES OR ENABLE_CPP_ST)
add_subdirectory(tests)
endif()

View File

@ -99,7 +99,11 @@ function(common_protobuf_generate path c_var h_var)
endfunction()
function(ms_protobuf_generate c_var h_var)
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto ${c_var} ${h_var} ${ARGN})
if(NOT ENABLE_CLOUD_AND_LITE)
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto ${c_var} ${h_var} ${ARGN})
else()
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto/lite ${c_var} ${h_var} ${ARGN})
endif()
set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE)
endfunction()

View File

@ -283,6 +283,14 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
)
endif()
if(ENABLE_CLOUD_AND_LITE)
install(
TARGETS mindspore-lite mslite_converter_plugin
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
# set python files
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/*.py)
install(

View File

@ -27,7 +27,7 @@
#include "include/api/context.h"
namespace mindspore {
class AclModelOptions {
class MS_API AclModelOptions {
public:
explicit AclModelOptions(const std::shared_ptr<Context> &context);
~AclModelOptions() = default;

View File

@ -28,7 +28,7 @@
#include "cxx_api/model/acl/acl_model_options.h"
namespace mindspore {
class ModelConverter {
class MS_API ModelConverter {
public:
ModelConverter() : options_() {}
~ModelConverter() = default;

View File

@ -227,6 +227,10 @@ int ThreadPool::CreateThreads(size_t thread_num, const std::vector<int> &core_li
return THREAD_OK;
}
int ThreadPool::ParallelLaunch(const TaskFunc &func, Content content, int task_num) const {
return ParallelLaunch(std::function<int(void *, int, float, float)>(func), content, task_num);
}
int ThreadPool::ParallelLaunch(const Func &func, Content content, int task_num) const {
// if single thread, run master thread
if (task_num <= 1) {

View File

@ -57,11 +57,9 @@ constexpr int kThreadIdle = 2; // idle, the thread is waiting
// used in scenarios with unequal division of task
// the parameters indicate the start and end coefficients
#ifdef BUILD_LITE
typedef int (*Func)(void *param, int task_id, float l, float r);
#else
typedef int (*TaskFunc)(void *param, int task_id, float l, float r);
using Func = std::function<int(void *, int, float, float)>;
#endif
using Content = void *;
typedef struct Task {
@ -164,6 +162,7 @@ class MS_CORE_API ThreadPool {
int SetCpuAffinity(BindMode bind_mode);
int SetProcessAffinity(BindMode bind_mode) const;
int ParallelLaunch(const TaskFunc &func, Content content, int task_num) const;
int ParallelLaunch(const Func &func, Content content, int task_num) const;
void DisableOccupiedActorThread() { occupied_actor_thread_ = false; }
void SetActorThreadNum(size_t actor_thread_num) { actor_thread_num_ = actor_thread_num; }

View File

@ -591,7 +591,7 @@ void mindspore_log_init(void) {
__attribute__((constructor)) void mindspore_log_init(void) {
#endif
#else
void mindspore_log_init(void) {
MS_CORE_API void mindspore_log_init(void) {
#endif
#ifdef USE_GLOG
#define google mindspore_private

View File

@ -12,7 +12,16 @@ set(MSLITE_GPU_BACKEND "" CACHE STRING "enable gpu backend, \
opencl only support arm64 and x86_64 , tensorrt only support x86_64, opencl/cuda/tensorrt/off")
set(MSLITE_REGISTRY_DEVICE "off" CACHE STRING "Compile Mindspore Lite that supports specific devices, \
currently supported devices: Hi3516D/Hi3519A/Hi3559A/SD3403")
set(MSLITE_MINDDATA_IMPLEMENT "lite_cv" CACHE STRING "off, lite_cv, cloud, or full")
if(NOT ENABLE_CLOUD_AND_LITE)
set(MSLITE_MINDDATA_IMPLEMENT "lite_cv" CACHE STRING "off, lite_cv, cloud, or full")
else()
remove_definitions(-DUSE_GLOG)
add_compile_definitions(ENABLE_CLOUD_AND_LITE)
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(PLATFORM_ARM64 "on")
set(MACHINE_LINUX_ARM64 "on")
endif()
endif()
option(MSLITE_ENABLE_NPU "enable npu, only arm64 or arm32 support" off)
option(MSLITE_ENABLE_TRAIN "enable train" on)
option(MSLITE_ENABLE_SSE "enable SSE instruction set, only x86_64 support" off)
@ -486,7 +495,9 @@ include_directories(${CCSRC_DIR}/minddata/dataset)
include(${TOP_DIR}/cmake/utils.cmake)
include(${TOP_DIR}/cmake/dependency_utils.cmake)
include(${TOP_DIR}/cmake/dependency_securec.cmake)
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
if(NOT ENABLE_CLOUD_AND_LITE)
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
endif()
if(MSLITE_GPU_BACKEND STREQUAL opencl)
include(${TOP_DIR}/cmake/external_libs/opencl.cmake)
@ -494,7 +505,9 @@ endif()
if(MSLITE_ENABLE_CONVERTER OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "full" OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "wrapper"
OR MSLITE_ENABLE_TOOLS)
include(${TOP_DIR}/cmake/external_libs/json.cmake)
if(NOT ENABLE_CLOUD_AND_LITE)
include(${TOP_DIR}/cmake/external_libs/json.cmake)
endif()
endif()
if(DEFINED ARCHS)
@ -576,7 +589,7 @@ if(ENABLE_MODEL_OBF)
set(OBF_LIBS libmsdeobfuscator-lite.so)
endif()
if(MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_RUNTIME_GLOG)
if((MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_RUNTIME_GLOG) AND NOT ENABLE_CLOUD_AND_LITE)
include(${TOP_DIR}/cmake/external_libs/glog.cmake)
endif()
@ -590,10 +603,12 @@ endfunction()
if(MSLITE_ENABLE_CONVERTER)
find_required_package(Patch)
include(${TOP_DIR}/cmake/external_libs/opencv.cmake)
include_directories(${PYTHON_INCLUDE_DIRS})
include(${TOP_DIR}/cmake/external_libs/eigen.cmake)
include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
if(NOT ENABLE_CLOUD_AND_LITE)
include(${TOP_DIR}/cmake/external_libs/opencv.cmake)
include(${TOP_DIR}/cmake/external_libs/eigen.cmake)
include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter)
endif()
@ -604,7 +619,7 @@ if(MSLITE_ENABLE_FP16)
endif()
endif()
if(MSLITE_ENABLE_MODEL_ENCRYPTION)
if(MSLITE_ENABLE_MODEL_ENCRYPTION AND NOT ENABLE_CLOUD_AND_LITE)
find_required_package(Patch)
include(${TOP_DIR}/cmake/external_libs/openssl.cmake)
add_compile_definitions(ENABLE_OPENSSL)
@ -672,9 +687,11 @@ if(ANDROID_NDK_TOOLCHAIN_INCLUDED)
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_subdirectory(${CCSRC_DIR}/plugin/device/cpu/kernel/nnacl build)
if(NOT ENABLE_CLOUD_AND_LITE)
add_subdirectory(${CCSRC_DIR}/plugin/device/cpu/kernel/nnacl build)
endif()
if(MSLITE_ENABLE_TOOLS)
if(MSLITE_ENABLE_TOOLS AND NOT ENABLE_CLOUD_AND_LITE)
if(NOT MSLITE_COMPILE_TWICE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark)
endif()
@ -693,7 +710,7 @@ if(NOT WIN32 AND MSLITE_ENABLE_TESTCASES)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
endif()
if(NOT APPLE)
if(NOT APPLE AND NOT ENABLE_CLOUD_AND_LITE)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/file_list.cmake)
include(${TOP_DIR}/cmake/package_lite.cmake)
endif()

View File

@ -1,4 +1,4 @@
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT ENABLE_CLOUD_AND_LITE)
set(CMAKE_SKIP_RPATH TRUE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_SKIP_INSTALL_RPATH TRUE)

View File

@ -314,7 +314,9 @@ if(MSLITE_ENABLE_V0)
endif()
if(MSLITE_ENABLE_MINDRT)
add_subdirectory(${CORE_DIR}/mindrt mindspore_mindrt)
if(NOT ENABLE_CLOUD_AND_LITE)
add_subdirectory(${CORE_DIR}/mindrt mindspore_mindrt)
endif()
set(LITE_SRC ${LITE_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/lite_mindrt.cc
${CMAKE_CURRENT_SOURCE_DIR}/mindrt_executor.cc
@ -534,3 +536,7 @@ if(MSLITE_ENABLE_ACL)
target_link_libraries(mindspore-lite ascend_kernel_mid)
target_link_libraries(mindspore-lite_static ascend_kernel_mid)
endif()
if(ENABLE_CLOUD_AND_LITE)
set_target_properties(mindspore-lite PROPERTIES INSTALL_RPATH $ORIGIN)
endif()

View File

@ -411,7 +411,7 @@ void InnerContext::ReplaceLinkInfoSenderWithNewOne(void *new_sender, void *old_s
}
}
int ParallelLaunch(const Context *context, const Func &func, Content content, int task_num) {
int ParallelLaunch(const Context *context, const TaskFunc &func, Content content, int task_num) {
ThreadPool *pool = static_cast<const lite::InnerContext *>(context)->thread_pool();
if (pool == nullptr) {
MS_LOG(ERROR) << "thread pool is nullptr";

View File

@ -127,7 +127,7 @@ struct InnerContext : public Context {
std::unordered_map<void *, std::set<void *>> link_info_{};
};
int ParallelLaunch(const Context *context, const Func &func, Content content, int task_num);
int ParallelLaunch(const Context *context, const TaskFunc &func, Content content, int task_num);
} // namespace mindspore::lite
#endif // MINDSPORE_LITE_SRC_INNER_CONTEXT_H

View File

@ -20,7 +20,11 @@
#include <string>
#include <vector>
#include "google/protobuf/message.h"
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/caffe.pb.h"
#else
#include "proto/caffe.pb.h"
#endif
#include "include/errorcode.h"
#include "schema/inner/model_generated.h"

View File

@ -66,13 +66,17 @@ add_subdirectory(quantizer)
add_subdirectory(registry)
add_subdirectory(preprocess)
add_subdirectory(config_parser)
add_subdirectory(${CORE_DIR} mindspore_core)
add_subdirectory(micro/coder)
if(NOT ENABLE_CLOUD_AND_LITE)
add_subdirectory(${CORE_DIR} mindspore_core)
endif()
if(MSLITE_ENABLE_ACL)
set(MODE_ASCEND_ACL ON)
include_directories(${TOP_DIR}/graphengine/inc/external)
include(${TOP_DIR}/cmake/dependency_graphengine.cmake)
if(NOT ENABLE_CLOUD_AND_LITE)
include(${TOP_DIR}/cmake/dependency_graphengine.cmake)
endif()
add_subdirectory(adapter/acl)
link_directories(${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH} ${ASCEND_CANN_RUNTIME_PATH})
endif()
@ -228,6 +232,9 @@ add_executable(converter_lite
${LITE_SRC}
)
add_dependencies(converter_lite fbs_src fbs_inner_src)
if(NOT ENABLE_CLOUD_AND_LITE)
add_dependencies(converter_lite nnacl_mid)
endif()
if((NOT WIN32) AND MSLITE_ENABLE_DPICO_ATC_ADAPTER)
add_dependencies(converter_lite dpico_atc_adapter)
endif()

View File

@ -22,13 +22,15 @@ file(GLOB ACL_SRC
set(ENABLE_ACL on)
set(MODE_ASCEND_ACL off)
add_subdirectory(${TOP_DIR}/mindspore/ccsrc/transform/graph_ir _mindspore_transform_graph_ir_obj)
add_subdirectory(${TOP_DIR}/mindspore/ccsrc/cxx_api mindspore_shared_lib)
if(NOT ENABLE_CLOUD_AND_LITE)
add_subdirectory(${TOP_DIR}/mindspore/ccsrc/transform/graph_ir _mindspore_transform_graph_ir_obj)
add_subdirectory(${TOP_DIR}/mindspore/ccsrc/cxx_api mindspore_shared_lib)
endif()
set_property(SOURCE ${ACL_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_LITE)
add_library(lite_acl_mid OBJECT ${ACL_SRC})
target_link_libraries(lite_acl_mid mindspore_shared_lib)
add_dependencies(lite_acl_mid mindspore_shared_lib)
add_dependencies(lite_acl_mid fbs_inner_src)
if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "cloud")

View File

@ -22,7 +22,11 @@
#include <unordered_map>
#include <memory>
#include <vector>
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/caffe.pb.h"
#else
#include "proto/caffe.pb.h"
#endif
#include "include/errorcode.h"
namespace mindspore {

View File

@ -23,7 +23,11 @@
#include <unordered_map>
#include "include/registry/model_parser.h"
#include "include/registry/model_parser_registry.h"
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/caffe.pb.h"
#else
#include "proto/caffe.pb.h"
#endif
#include "ops/primitive_c.h"
using STATUS = int;

View File

@ -21,7 +21,11 @@
#include <vector>
#include "google/protobuf/message.h"
#include "schema/inner/model_generated.h"
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/caffe.pb.h"
#else
#include "proto/caffe.pb.h"
#endif
#include "tools/converter/parser/caffe/caffe_node_parser.h"
#include "include/errorcode.h"
#include "src/common/log_adapter.h"

View File

@ -20,7 +20,11 @@
#include <string>
#include <unordered_map>
#include "tools/converter/parser/caffe/caffe_node_parser.h"
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/caffe.pb.h"
#else
#include "proto/caffe.pb.h"
#endif
namespace mindspore::lite {
class CaffeNodeParserRegistry {

View File

@ -30,7 +30,11 @@
#include "include/registry/model_parser.h"
#include "include/registry/model_parser_registry.h"
#include "tools/converter/parser/onnx/onnx_node_parser_registry.h"
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/onnx.pb.h"
#else
#include "proto/onnx.pb.h"
#endif
#include "schema/inner/model_generated.h"
namespace mindspore {

View File

@ -21,7 +21,11 @@
#include <utility>
#include <vector>
#include "google/protobuf/message.h"
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/onnx.pb.h"
#else
#include "proto/onnx.pb.h"
#endif
#include "include/errorcode.h"
#include "src/common/log_adapter.h"
#include "schema/inner/model_generated.h"

View File

@ -24,8 +24,13 @@
#include <vector>
#include <set>
#include <utility>
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/graph.pb.h"
#include "proto/lite/node_def.pb.h"
#else
#include "proto/graph.pb.h"
#include "proto/node_def.pb.h"
#endif
#include "schema/inner/model_generated.h"
#include "securec/include/securec.h"
#include "tools/common/tensor_util.h"

View File

@ -22,7 +22,11 @@
#include <map>
#include <memory>
#include "tools/converter/parser/tf/tf_util.h"
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/graph.pb.h"
#else
#include "proto/graph.pb.h"
#endif
#include "ops/primitive_c.h"
#include "mindspore/core/utils/check_convert_utils.h"
#include "nnacl/op_base.h"

View File

@ -19,7 +19,11 @@
#include <string>
#include <string_view>
#ifdef ENABLE_CLOUD_AND_LITE
#include "proto/lite/node_def.pb.h"
#else
#include "proto/node_def.pb.h"
#endif
#include "ir/dtype/type_id.h"
#include "include/errorcode.h"
#include "schema/inner/model_generated.h"