diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c49ed74469..0a4ece8a1f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,9 +105,11 @@ 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}) + set(ENABLE_CLOUD_AND_LITE $ENV{ENABLE_CLOUD_AND_LITE}) endif() if(ENABLE_CLOUD_AND_LITE) + set(ENV{MSLITE_ENABLE_RUNTIME_CONVERT} "on") + set(ENV{MSLITE_ENABLE_ACL} "on") add_subdirectory(mindspore/lite) endif() diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index 38fd4f21a7d..c50da0e855e 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -98,7 +98,10 @@ endif() if(DEFINED ENV{MSLITE_ENABLE_CONVERTER}) set(MSLITE_ENABLE_CONVERTER $ENV{MSLITE_ENABLE_CONVERTER}) endif() -if(DEFINED ENV{ENABLE_AKG}) +if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) + set(MSLITE_ENABLE_RUNTIME_CONVERT $ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) +endif() +if(DEFINED ENV{ENABLE_AKG} AND NOT MSLITE_ENABLE_RUNTIME_CONVERT) set(MSLITE_ENABLE_GRAPH_KERNEL $ENV{ENABLE_AKG}) endif() if(DEFINED ENV{MSLITE_ENABLE_TOOLS}) @@ -161,10 +164,6 @@ if(DEFINED ENV{MSLITE_ENABLE_MODEL_ENCRYPTION}) endif() endif() -if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) - set(MSLITE_ENABLE_RUNTIME_CONVERT $ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) -endif() - if(DEFINED ENV{MSLITE_ENABLE_COVERAGE}) set(MSLITE_ENABLE_COVERAGE $ENV{MSLITE_ENABLE_COVERAGE}) endif() diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt index 9bf07eb579a..7d1ca651f6a 100644 --- a/mindspore/lite/src/CMakeLists.txt +++ b/mindspore/lite/src/CMakeLists.txt @@ -488,12 +488,14 @@ if(MSLITE_ENABLE_RUNTIME_CONVERT) quantizer_mid fusion_mid proto_mid graph_pass_mid preprocess_mid cpu_kernel_mid ccsrc_src_mid converter_src_mid anf_exporter_mid config_parser_mid mslite_converter_plugin mindspore_core coder_mid - mindspore::protobuf ${SECUREC_LIBRARY}) + ccsrc_debug_common_mid_ mindir_proto_mid _mindspore_transform_express_ir_obj + mindir_serializer_mid mindspore::protobuf ${SECUREC_LIBRARY}) target_link_libraries(mindspore-lite_static quantizer_mid fusion_mid proto_mid graph_pass_mid preprocess_mid cpu_kernel_mid ccsrc_src_mid converter_src_mid anf_exporter_mid config_parser_mid mslite_converter_plugin mindspore_core coder_mid - mindspore::protobuf ${SECUREC_LIBRARY}) + ccsrc_debug_common_mid_ mindir_proto_mid _mindspore_transform_express_ir_obj + mindir_serializer_mid mindspore::protobuf ${SECUREC_LIBRARY}) if(MSLITE_ENABLE_ACL) target_link_libraries(mindspore-lite lite_acl_mid mindspore_shared_lib) diff --git a/mindspore/lite/tools/converter/CMakeLists.txt b/mindspore/lite/tools/converter/CMakeLists.txt index 5f3db33fbdf..c994cb46a23 100644 --- a/mindspore/lite/tools/converter/CMakeLists.txt +++ b/mindspore/lite/tools/converter/CMakeLists.txt @@ -302,12 +302,14 @@ target_link_libraries(converter_lite PRIVATE preprocess_mid config_parser_mid coder_mid - ccsrc_debug_common_mid_ - mindir_proto_mid - _mindspore_transform_express_ir_obj mindir_serializer_mid ) - +if(NOT ENABLE_CLOUD_AND_LITE) + target_link_libraries(converter_lite PRIVATE + ccsrc_debug_common_mid_ + mindir_proto_mid + _mindspore_transform_express_ir_obj) +endif() if(MSLITE_ENABLE_ACL) target_link_libraries(converter_lite PRIVATE lite_acl_mid diff --git a/mindspore/lite/tools/mindir_serializer/CMakeLists.txt b/mindspore/lite/tools/mindir_serializer/CMakeLists.txt index 31b945bda8f..6a8933feeae 100644 --- a/mindspore/lite/tools/mindir_serializer/CMakeLists.txt +++ b/mindspore/lite/tools/mindir_serializer/CMakeLists.txt @@ -14,8 +14,10 @@ add_library(mindir_proto_mid OBJECT ${PROTO_SRCS}) add_compile_definitions(MINDIR_EXPORT_TENSOR_LAYOUT_CLIP) add_compile_definitions(COMMON_DLL) -set(MINDIR_EXPORT_DIR ${CCSRC_DIR}/transform/express_ir) -add_subdirectory(${MINDIR_EXPORT_DIR} mindir_exporter) +if(NOT ENABLE_CLOUD_AND_LITE) + set(MINDIR_EXPORT_DIR ${CCSRC_DIR}/transform/express_ir) + add_subdirectory(${MINDIR_EXPORT_DIR} mindir_exporter) +endif() add_library(mindir_serializer_mid OBJECT ${MINDIR_EXPORTER_SRC_LIST} diff --git a/mindspore/lite/tools/mindir_serializer/mindir_serializer.cc b/mindspore/lite/tools/mindir_serializer/mindir_serializer.cc index c52e6f1acd8..e0db7882aad 100644 --- a/mindspore/lite/tools/mindir_serializer/mindir_serializer.cc +++ b/mindspore/lite/tools/mindir_serializer/mindir_serializer.cc @@ -30,6 +30,7 @@ namespace mindspore::lite { constexpr const size_t TOTAL_SAVE = 1024 * 1024 * 1024; constexpr const int64_t OFFSET = 64; +#ifndef ENABLE_CLOUD_AND_LITE namespace { bool DeleteDirRecursively(const std::string &dir_name) { DIR *dir = opendir(dir_name.c_str()); @@ -400,16 +401,18 @@ int MindIRSerializer::SaveProtoToFile(mind_ir::ModelProto *model_proto, const st ChangeFileMode(realpath.value(), S_IRUSR); return RET_OK; } +#endif int MindIRSerialize(const std::unique_ptr &flag, const FuncGraphPtr &func_graph) { +#ifndef ENABLE_CLOUD_AND_LITE if (!flag->export_mindir) { return RET_OK; } -#if defined(SYSTEM_ENV_WINDOWS) - MS_LOG(WARNING) << "mindir serialize not support windows now."; - return RET_NOT_SUPPORT; -#endif mindspore::lite::MindIRSerializer serializer; return serializer.Save(flag, func_graph); +#else + MS_LOG(INFO) << "No need to serialize mindir when load model online."; + return RET_OK; +#endif } } // namespace mindspore::lite diff --git a/mindspore/lite/tools/mindir_serializer/mindir_serializer.h b/mindspore/lite/tools/mindir_serializer/mindir_serializer.h index 36b7df24328..a067e1a41f5 100644 --- a/mindspore/lite/tools/mindir_serializer/mindir_serializer.h +++ b/mindspore/lite/tools/mindir_serializer/mindir_serializer.h @@ -29,6 +29,7 @@ #include "mindspore/core/utils/system/env.h" namespace mindspore::lite { +#ifndef ENABLE_CLOUD_AND_LITE class MindIRSerializer { public: MindIRSerializer() = default; @@ -71,7 +72,7 @@ class MindIRSerializer { std::fstream *data_fs_ = nullptr; std::shared_ptr fs_{}; }; - +#endif // export func_graph int MindIRSerialize(const std::unique_ptr &flag, const FuncGraphPtr &func_graph); } // namespace mindspore::lite diff --git a/scripts/build/parse_device.sh b/scripts/build/parse_device.sh index 338ae0ac643..cb076b949f9 100755 --- a/scripts/build/parse_device.sh +++ b/scripts/build/parse_device.sh @@ -56,6 +56,7 @@ parse_device() ENABLE_CPU="on" export ENABLE_MPI="on" export ENABLE_AKG="on" + export ENABLE_CLOUD_AND_LITE="on" else echo "Invalid value ${DEVICE_VERSION} for option -V" usage