From 40899f7b80fada928b79a6cca8b92899277c94a1 Mon Sep 17 00:00:00 2001 From: xuanyue Date: Mon, 24 May 2021 14:47:52 +0800 Subject: [PATCH] adjust kernel_reg dynamic lib --- build.sh | 12 ----- cmake/package_lite.cmake | 36 +++++++-------- mindspore/core/ir/format.h | 46 +++++++++++++++++++ mindspore/core/utils/check_convert_utils.h | 21 +-------- mindspore/lite/CMakeLists.txt | 1 - .../train_lenet/model/prepare_model.sh | 2 +- .../transfer_learning/model/prepare_model.sh | 2 +- .../registry/kernel_interface.h | 0 .../registry/model_parser_registry.h | 0 .../registry/pass_registry.h | 0 .../registry/register_kernel.h | 0 mindspore/lite/src/CMakeLists.txt | 10 ++-- mindspore/lite/src/kernel_registry.cc | 2 +- mindspore/lite/src/registry/CMakeLists.txt | 12 ----- .../lite/src/registry/kernel_interface.cc | 2 +- .../src/registry/kernel_interface_registry.cc | 2 +- .../src/registry/kernel_interface_registry.h | 2 +- .../lite/src/registry/register_kernel.cc | 2 +- .../lite/src/registry/register_kernel_impl.cc | 2 +- .../lite/src/registry/register_kernel_impl.h | 2 +- mindspore/lite/src/runtime/infer_manager.cc | 2 +- mindspore/lite/src/scheduler.cc | 4 +- mindspore/lite/test/CMakeLists.txt | 7 +-- mindspore/lite/test/run_benchmark_nets.sh | 6 --- mindspore/lite/test/st/run_net_train.sh | 1 - .../lite/test/st/scripts/run_benchmark_arm.sh | 4 -- .../lite/test/st/scripts/run_benchmark_gpu.sh | 1 - .../lite/test/st/scripts/run_benchmark_npu.sh | 1 - mindspore/lite/test/st/scripts/run_cropper.sh | 5 +- mindspore/lite/tools/converter/CMakeLists.txt | 1 - .../lite/tools/converter/anf_transform.cc | 2 +- mindspore/lite/tools/converter/converter.cc | 2 +- mindspore/lite/tools/converter/converter.h | 2 +- .../parser/caffe/caffe_model_parser.h | 2 +- .../converter/parser/onnx/onnx_model_parser.h | 2 +- .../converter/parser/tf/tf_model_parser.h | 2 +- .../parser/tflite/tflite_model_parser.h | 2 +- .../tools/converter/registry/CMakeLists.txt | 14 ++++-- .../registry/model_parser_registry.cc | 2 +- .../tools/converter/registry/pass_registry.cc | 6 +-- .../tools/cropper/build_cropper_config.sh | 8 +++- 41 files changed, 115 insertions(+), 117 deletions(-) create mode 100644 mindspore/core/ir/format.h rename mindspore/lite/{src => include}/registry/kernel_interface.h (100%) rename mindspore/lite/{tools/converter => include}/registry/model_parser_registry.h (100%) rename mindspore/lite/{tools/converter => include}/registry/pass_registry.h (100%) rename mindspore/lite/{src => include}/registry/register_kernel.h (100%) delete mode 100644 mindspore/lite/src/registry/CMakeLists.txt diff --git a/build.sh b/build.sh index cdbf9b39583..05418355957 100755 --- a/build.sh +++ b/build.sh @@ -725,8 +725,6 @@ build_lite_java_arm64() { if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/java/app/libs/arm64-v8a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/native/libs/arm64-v8a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmslite_kernel_reg.so ${JAVA_PATH}/java/app/libs/arm64-v8a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmslite_kernel_reg.so ${JAVA_PATH}/native/libs/arm64-v8a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/java/app/libs/arm64-v8a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/native/libs/arm64-v8a/ @@ -736,8 +734,6 @@ build_lite_java_arm64() { else cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/java/app/libs/arm64-v8a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/native/libs/arm64-v8a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmslite_kernel_reg.so ${JAVA_PATH}/java/app/libs/arm64-v8a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmslite_kernel_reg.so ${JAVA_PATH}/native/libs/arm64-v8a/ fi [ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name} } @@ -761,8 +757,6 @@ build_lite_java_arm32() { if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/native/libs/armeabi-v7a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmslite_kernel_reg.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmslite_kernel_reg.so ${JAVA_PATH}/native/libs/armeabi-v7a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/native/libs/armeabi-v7a/ @@ -772,8 +766,6 @@ build_lite_java_arm32() { else cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/native/libs/armeabi-v7a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmslite_kernel_reg.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmslite_kernel_reg.so ${JAVA_PATH}/native/libs/armeabi-v7a/ fi [ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name} } @@ -798,8 +790,6 @@ build_lite_java_x86() { if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/java/linux_x86/libs/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/native/libs/linux_x86/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmslite_kernel_reg.so ${JAVA_PATH}/java/linux_x86/libs/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmslite_kernel_reg.so ${JAVA_PATH}/native/libs/linux_x86/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/java/linux_x86/libs/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/native/libs/linux_x86/ @@ -809,8 +799,6 @@ build_lite_java_x86() { else cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/java/linux_x86/libs/ cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/native/libs/linux_x86/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmslite_kernel_reg.so ${JAVA_PATH}/java/linux_x86/libs/ - cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmslite_kernel_reg.so ${JAVA_PATH}/native/libs/linux_x86/ fi [ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name} } diff --git a/cmake/package_lite.cmake b/cmake/package_lite.cmake index 699b7d06e66..591188bd7dd 100644 --- a/cmake/package_lite.cmake +++ b/cmake/package_lite.cmake @@ -161,17 +161,16 @@ if(PLATFORM_ARM64) endif() if(SUPPORT_TRAIN) install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "*registry.h" EXCLUDE) else() install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE) + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE + PATTERN "*registry.h" EXCLUDE) endif() install(FILES ${TOP_DIR}/mindspore/lite/build/src/${MINDSPORE_LITE_LIB_NAME}.so DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/mindspore/lite/build/src/${MINDSPORE_LITE_LIB_NAME}.a DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) - install(FILES ${TOP_DIR}/mindspore/lite/build/src/registry/libmslite_kernel_reg.so - DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) if(ENABLE_MODEL_OBF) install(FILES ${TOP_DIR}/mindspore/lite/tools/obfuscator/lib/android-aarch64/libmsdeobfuscator-lite.so DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) @@ -207,17 +206,16 @@ elseif(PLATFORM_ARM32) endif() if(SUPPORT_TRAIN) install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "*registry.h" EXCLUDE) else() install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE) + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE + PATTERN "*registry.h" EXCLUDE) endif() install(FILES ${TOP_DIR}/mindspore/lite/build/src/${MINDSPORE_LITE_LIB_NAME}.so DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/mindspore/lite/build/src/${MINDSPORE_LITE_LIB_NAME}.a DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) - install(FILES ${TOP_DIR}/mindspore/lite/build/src/registry/libmslite_kernel_reg.so - DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) if(ENABLE_MODEL_OBF) install(FILES ${TOP_DIR}/mindspore/lite/tools/obfuscator/lib/android-aarch32/libmsdeobfuscator-lite.so DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) @@ -249,11 +247,11 @@ elseif(WIN32) if(ENABLE_CONVERTER) install(TARGETS converter_lite RUNTIME DESTINATION ${CONVERTER_ROOT_DIR}/converter COMPONENT ${RUNTIME_COMPONENT_NAME}) + install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/registry/ DESTINATION ${CONVERTER_ROOT_DIR}/include/registry + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") install(FILES ${LIB_LIST} DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/build/mindspore/tools/converter/registry/libmslite_converter_plugin_reg.dll DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) - install(FILES ${TOP_DIR}/build/mindspore/src/registry/libmslite_kernel_reg.dll - DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${glog_LIBPATH}/../bin/libglog.dll DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${NNACL_FILES} DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl COMPONENT ${RUNTIME_COMPONENT_NAME}) @@ -287,10 +285,11 @@ elseif(WIN32) COMPONENT ${RUNTIME_COMPONENT_NAME}) if(SUPPORT_TRAIN) install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "*registry.h" EXCLUDE) else() install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE) + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE + PATTERN "*registry.h" EXCLUDE) endif() install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${RUNTIME_INC_DIR}/ir/dtype COMPONENT ${RUNTIME_COMPONENT_NAME}) @@ -302,15 +301,14 @@ elseif(WIN32) COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.dll DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) - install(FILES ${TOP_DIR}/build/mindspore/src/registry/libmslite_kernel_reg.dll DESTINATION ${RUNTIME_LIB_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME}) else() if(SUPPORT_TRAIN) install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "*registry.h" EXCLUDE) else() install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE) + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "train*" EXCLUDE + PATTERN "*registry.h" EXCLUDE) endif() install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${RUNTIME_INC_DIR}/ir/dtype COMPONENT ${RUNTIME_COMPONENT_NAME}) @@ -320,8 +318,6 @@ else() COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/mindspore/lite/build/src/${MINDSPORE_LITE_LIB_NAME}.a DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) - install(FILES ${TOP_DIR}/mindspore/lite/build/src/registry/libmslite_kernel_reg.so DESTINATION ${RUNTIME_LIB_DIR} - COMPONENT ${RUNTIME_COMPONENT_NAME}) if(ENABLE_MODEL_OBF) install(FILES ${TOP_DIR}/mindspore/lite/tools/obfuscator/bin/linux-x64/msobfuscator DESTINATION ${OBFUSCATOR_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) @@ -329,12 +325,12 @@ else() DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) endif() if(ENABLE_CONVERTER) + install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/registry/ DESTINATION ${CONVERTER_ROOT_DIR}/include/registry + COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") install(TARGETS converter_lite RUNTIME DESTINATION ${CONVERTER_ROOT_DIR}/converter COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/mindspore/lite/build/tools/converter/registry/libmslite_converter_plugin_reg.so DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) - install(FILES ${TOP_DIR}/mindspore/lite/build/src/registry/libmslite_kernel_reg.so - DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${CONVERTER_ROOT_DIR}/lib RENAME libglog.so.0 COMPONENT ${RUNTIME_COMPONENT_NAME}) file(GLOB NNACL_FILES GLOB ${NNACL_DIR}/*.h) diff --git a/mindspore/core/ir/format.h b/mindspore/core/ir/format.h new file mode 100644 index 00000000000..be3fe63fd9d --- /dev/null +++ b/mindspore/core/ir/format.h @@ -0,0 +1,46 @@ +/** + * This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/). + * + * Copyright 2021 Huawei Technologies Co., Ltd + * + * 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. + */ + +#ifndef MINDSPORE_CORE_IR_FORMAT_H_ +#define MINDSPORE_CORE_IR_FORMAT_H_ + +#include + +namespace mindspore { +enum Format : int64_t { + NCHW = 0, + NHWC = 1, + NHWC4 = 2, + HWKC = 3, + HWCK = 4, + KCHW = 5, + CKHW = 6, + KHWC = 7, + CHWK = 8, + HW = 9, + HW4 = 10, + NC = 11, + NC4 = 12, + NC4HW4 = 13, + NUM_OF_FORMAT = 14, + NCDHW = 15, + NWC = 16, + NCW = 17 +}; +} // namespace mindspore +#endif // MINDSPORE_CORE_IR_FORMAT_H_ diff --git a/mindspore/core/utils/check_convert_utils.h b/mindspore/core/utils/check_convert_utils.h index 7687c77f15d..ec9c25cdb0b 100644 --- a/mindspore/core/utils/check_convert_utils.h +++ b/mindspore/core/utils/check_convert_utils.h @@ -27,6 +27,7 @@ #include "base/base.h" #include "ir/anf.h" #include "ir/dtype/type_id.h" +#include "ir/format.h" #include "utils/log_adapter.h" namespace mindspore { typedef std::pair, std::map> AttrConverterPair; @@ -50,26 +51,6 @@ enum CompareRange { kIncludeRight = 3, // (a,b] kIncludeBoth = 4, // [a,b] }; -enum Format : int64_t { - NCHW = 0, - NHWC = 1, - NHWC4 = 2, - HWKC = 3, - HWCK = 4, - KCHW = 5, - CKHW = 6, - KHWC = 7, - CHWK = 8, - HW = 9, - HW4 = 10, - NC = 11, - NC4 = 12, - NC4HW4 = 13, - NUM_OF_FORMAT = 14, - NCDHW = 15, - NWC = 16, - NCW = 17 -}; enum ActivationType : int64_t { NO_ACTIVATION = 0, RELU = 1, diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index f8a86bdb06b..387849fc404 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -278,7 +278,6 @@ if(BUILD_MINDDATA STREQUAL "lite_cv") endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/registry) add_subdirectory(${CCSRC_DIR}/backend/kernel_compiler/cpu/nnacl build) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro/coder) if(NOT APPLE AND ENABLE_TOOLS) diff --git a/mindspore/lite/examples/train_lenet/model/prepare_model.sh b/mindspore/lite/examples/train_lenet/model/prepare_model.sh index 7c8992802bb..527cc8b2dea 100755 --- a/mindspore/lite/examples/train_lenet/model/prepare_model.sh +++ b/mindspore/lite/examples/train_lenet/model/prepare_model.sh @@ -14,7 +14,7 @@ CONVERTER="../../../build/tools/converter/converter_lite" if [ ! -f "$CONVERTER" ]; then if ! command -v converter_lite &> /dev/null then - tar -xzf ../../../../../output/mindspore-lite-*-train-linux-x64.tar.gz --strip-components 4 --wildcards --no-anchored converter_lite libglog.so.0 libmslite_kernel_reg.so libmslite_converter_plugin_reg.so + tar -xzf ../../../../../output/mindspore-lite-*-train-linux-x64.tar.gz --strip-components 4 --wildcards --no-anchored converter_lite libglog.so.0 libmslite_converter_plugin_reg.so if [ -f ./converter_lite ]; then CONVERTER=./converter_lite else diff --git a/mindspore/lite/examples/transfer_learning/model/prepare_model.sh b/mindspore/lite/examples/transfer_learning/model/prepare_model.sh index f79a32d2bc2..b19b600f443 100755 --- a/mindspore/lite/examples/transfer_learning/model/prepare_model.sh +++ b/mindspore/lite/examples/transfer_learning/model/prepare_model.sh @@ -19,7 +19,7 @@ CONVERTER="../../../build/tools/converter/converter_lite" if [ ! -f "$CONVERTER" ]; then if ! command -v converter_lite &> /dev/null then - tar -xzf ../../../../../output/mindspore-lite-*-train-linux-x64.tar.gz --strip-components 4 --wildcards --no-anchored converter_lite libglog.so.0 libmslite_kernel_reg.so libmslite_converter_plugin_reg.so + tar -xzf ../../../../../output/mindspore-lite-*-train-linux-x64.tar.gz --strip-components 4 --wildcards --no-anchored converter_lite libglog.so.0 libmslite_converter_plugin_reg.so if [ -f ./converter_lite ]; then CONVERTER=./converter_lite else diff --git a/mindspore/lite/src/registry/kernel_interface.h b/mindspore/lite/include/registry/kernel_interface.h similarity index 100% rename from mindspore/lite/src/registry/kernel_interface.h rename to mindspore/lite/include/registry/kernel_interface.h diff --git a/mindspore/lite/tools/converter/registry/model_parser_registry.h b/mindspore/lite/include/registry/model_parser_registry.h similarity index 100% rename from mindspore/lite/tools/converter/registry/model_parser_registry.h rename to mindspore/lite/include/registry/model_parser_registry.h diff --git a/mindspore/lite/tools/converter/registry/pass_registry.h b/mindspore/lite/include/registry/pass_registry.h similarity index 100% rename from mindspore/lite/tools/converter/registry/pass_registry.h rename to mindspore/lite/include/registry/pass_registry.h diff --git a/mindspore/lite/src/registry/register_kernel.h b/mindspore/lite/include/registry/register_kernel.h similarity index 100% rename from mindspore/lite/src/registry/register_kernel.h rename to mindspore/lite/include/registry/register_kernel.h diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt index 4bbbfa847e0..654e762f6d3 100644 --- a/mindspore/lite/src/CMakeLists.txt +++ b/mindspore/lite/src/CMakeLists.txt @@ -47,6 +47,7 @@ set(LITE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/common/utils.cc ${CMAKE_CURRENT_SOURCE_DIR}/common/graph_util.cc ${CMAKE_CURRENT_SOURCE_DIR}/common/dynamic_library_loader.cc + ${CMAKE_CURRENT_SOURCE_DIR}/common/log_adapter.cc ${CMAKE_CURRENT_SOURCE_DIR}/common/string_util.cc ${CMAKE_CURRENT_SOURCE_DIR}/common/prim_util.cc ${CMAKE_CURRENT_SOURCE_DIR}/common/tensor_util.cc @@ -75,6 +76,8 @@ set(LITE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/cpu_info.cc ) +file(GLOB KERNEL_REG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/registry/*.cc) +set(LITE_SRC ${LITE_SRC} ${KERNEL_REG_SRC}) if(SUPPORT_GPU STREQUAL opencl) file(GLOB_RECURSE OPENCL_RUNTIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/gpu/opencl/*.cc @@ -181,6 +184,10 @@ if(SUPPORT_NPU) target_link_libraries(mindspore-lite npu_kernel_mid) target_link_libraries(mindspore-lite_static npu_kernel_mid) endif() +if(PLATFORM_ARM32 OR PLATFORM_ARM64) + target_link_libraries(mindspore-lite log) + target_link_libraries(mindspore-lite_static log) +endif() if(BUILD_MINDDATA STREQUAL "lite") target_link_libraries(mindspore-lite minddata_eager_mid minddata-lite) target_link_libraries(mindspore-lite_static minddata_eager_mid) @@ -192,9 +199,6 @@ if(SUPPORT_TRAIN) target_link_libraries(mindspore-lite_static minddata-lite) endif() -target_link_libraries(mindspore-lite mslite_kernel_reg) -target_link_libraries(mindspore-lite_static mslite_kernel_reg) - if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") if(NOT APPLE AND PLATFORM_ARM) set(NDK_STRIP diff --git a/mindspore/lite/src/kernel_registry.cc b/mindspore/lite/src/kernel_registry.cc index bf627cf0a22..5b12cf05d76 100644 --- a/mindspore/lite/src/kernel_registry.cc +++ b/mindspore/lite/src/kernel_registry.cc @@ -16,7 +16,7 @@ #include "src/kernel_registry.h" #include #include "include/errorcode.h" -#include "src/registry/register_kernel.h" +#include "include/registry/register_kernel.h" #include "src/ops/populate/populate_register.h" #include "src/common/version_manager.h" #include "nnacl/pooling_parameter.h" diff --git a/mindspore/lite/src/registry/CMakeLists.txt b/mindspore/lite/src/registry/CMakeLists.txt deleted file mode 100644 index 78778a1cd23..00000000000 --- a/mindspore/lite/src/registry/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -file(GLOB RUNTIME_REG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) -if(USE_GLOG) - set(RUNTIME_REG_SRC ${RUNTIME_REG_SRC} ${CORE_DIR}/utils/log_adapter.cc) -else() - set(RUNTIME_REG_SRC ${RUNTIME_REG_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/../common/log_adapter.cc) -endif() -set_property(SOURCE ${RUNTIME_REG_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_LITE) -add_library(mslite_kernel_reg SHARED ${RUNTIME_REG_SRC}) -if(PLATFORM_ARM32 OR PLATFORM_ARM64) - target_link_libraries(mslite_kernel_reg log) -endif() -add_dependencies(mslite_kernel_reg fbs_src) \ No newline at end of file diff --git a/mindspore/lite/src/registry/kernel_interface.cc b/mindspore/lite/src/registry/kernel_interface.cc index 74ad66f77b4..144b2033ae1 100644 --- a/mindspore/lite/src/registry/kernel_interface.cc +++ b/mindspore/lite/src/registry/kernel_interface.cc @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "src/registry/kernel_interface.h" +#include "include/registry/kernel_interface.h" #include #include #include "src/registry/kernel_interface_registry.h" diff --git a/mindspore/lite/src/registry/kernel_interface_registry.cc b/mindspore/lite/src/registry/kernel_interface_registry.cc index 20404cc09d0..054b3599d4f 100644 --- a/mindspore/lite/src/registry/kernel_interface_registry.cc +++ b/mindspore/lite/src/registry/kernel_interface_registry.cc @@ -15,7 +15,7 @@ */ #include "src/registry/kernel_interface_registry.h" #include -#include "src/registry/kernel_interface.h" +#include "include/registry/kernel_interface.h" #include "include/errorcode.h" #include "src/common/log_adapter.h" #include "src/common/version_manager.h" diff --git a/mindspore/lite/src/registry/kernel_interface_registry.h b/mindspore/lite/src/registry/kernel_interface_registry.h index bb80c5f5dd3..cd819d944b1 100644 --- a/mindspore/lite/src/registry/kernel_interface_registry.h +++ b/mindspore/lite/src/registry/kernel_interface_registry.h @@ -22,7 +22,7 @@ #include #include #include -#include "src/registry/kernel_interface.h" +#include "include/registry/kernel_interface.h" #include "include/model.h" namespace mindspore { diff --git a/mindspore/lite/src/registry/register_kernel.cc b/mindspore/lite/src/registry/register_kernel.cc index 3855e74c2f0..8d2ea5657bc 100644 --- a/mindspore/lite/src/registry/register_kernel.cc +++ b/mindspore/lite/src/registry/register_kernel.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "src/registry/register_kernel.h" +#include "include/registry/register_kernel.h" #include #include "src/registry/register_kernel_impl.h" diff --git a/mindspore/lite/src/registry/register_kernel_impl.cc b/mindspore/lite/src/registry/register_kernel_impl.cc index ac99103d6bc..7542fee082c 100644 --- a/mindspore/lite/src/registry/register_kernel_impl.cc +++ b/mindspore/lite/src/registry/register_kernel_impl.cc @@ -14,7 +14,7 @@ * limitations under the License. */ #include "src/registry/register_kernel_impl.h" -#include "src/registry/register_kernel.h" +#include "include/registry/register_kernel.h" #include "include/errorcode.h" #include "src/common/version_manager.h" #include "src/common/log_adapter.h" diff --git a/mindspore/lite/src/registry/register_kernel_impl.h b/mindspore/lite/src/registry/register_kernel_impl.h index 85d9fc5d52f..9025c317ae6 100644 --- a/mindspore/lite/src/registry/register_kernel_impl.h +++ b/mindspore/lite/src/registry/register_kernel_impl.h @@ -23,7 +23,7 @@ #include #include #include -#include "src/registry/register_kernel.h" +#include "include/registry/register_kernel.h" using mindspore::schema::PrimitiveType_MAX; using mindspore::schema::PrimitiveType_MIN; diff --git a/mindspore/lite/src/runtime/infer_manager.cc b/mindspore/lite/src/runtime/infer_manager.cc index b84784ce8f7..e6ed07a1aca 100644 --- a/mindspore/lite/src/runtime/infer_manager.cc +++ b/mindspore/lite/src/runtime/infer_manager.cc @@ -23,7 +23,7 @@ #include "include/errorcode.h" #include "nnacl/errorcode.h" #include "src/tensorlist.h" -#include "src/registry/kernel_interface.h" +#include "include/registry/kernel_interface.h" #include "src/kernel_registry.h" namespace mindspore { diff --git a/mindspore/lite/src/scheduler.cc b/mindspore/lite/src/scheduler.cc index 36566e2870b..d7d3d7a2ea5 100644 --- a/mindspore/lite/src/scheduler.cc +++ b/mindspore/lite/src/scheduler.cc @@ -25,7 +25,7 @@ #include "src/common/graph_util.h" #include "src/common/utils.h" #include "src/kernel_registry.h" -#include "src/registry/register_kernel.h" +#include "include/registry/register_kernel.h" #include "src/lite_kernel_util.h" #include "src/sub_graph_kernel.h" #include "src/ops/populate/populate_register.h" @@ -49,7 +49,7 @@ #if defined(ENABLE_ARM) && defined(ENABLE_FP16) #include "src/runtime/kernel/arm/fp16/fp16_op_handler.h" #endif -#include "src/registry/kernel_interface.h" +#include "include/registry/kernel_interface.h" namespace mindspore::lite { using kernel::KERNEL_ARCH::kCPU; diff --git a/mindspore/lite/test/CMakeLists.txt b/mindspore/lite/test/CMakeLists.txt index 7176e3aa447..d86e482f422 100644 --- a/mindspore/lite/test/CMakeLists.txt +++ b/mindspore/lite/test/CMakeLists.txt @@ -19,6 +19,7 @@ if(ENABLE_CONVERTER) ${CCSRC_DIR}/backend/optimizer/common/optimizer.cc ) else() + set(TEST_LITE_SRC ${LITE_DIR}/src/common/log_adapter.cc) add_compile_definitions(USE_ANDROID_LOG) endif() @@ -107,6 +108,9 @@ set(TEST_LITE_SRC ${LITE_DIR}/tools/common/flag_parser.cc ) +file(GLOB KERNEL_REG_SRC ${LITE_DIR}/src/registry/*.cc) +set(TEST_LITE_SRC ${TEST_LITE_SRC} ${KERNEL_REG_SRC}) + if(ENABLE_TOOLS) set(TEST_LITE_SRC ${TEST_LITE_SRC} @@ -393,9 +397,6 @@ if(ENABLE_CONVERTER) mindspore::glog ) endif() - -target_link_libraries(lite-test mslite_kernel_reg) - if(ENABLE_MODEL_OBF) target_link_libraries(lite-test ${OBF_LIB_DIR}/libmsdeobfuscator-lite.so) endif() diff --git a/mindspore/lite/test/run_benchmark_nets.sh b/mindspore/lite/test/run_benchmark_nets.sh index 9c44a361574..4a26dc7c911 100644 --- a/mindspore/lite/test/run_benchmark_nets.sh +++ b/mindspore/lite/test/run_benchmark_nets.sh @@ -1482,7 +1482,6 @@ function Run_arm64() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -1903,7 +1902,6 @@ function Run_arm32() { cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir.so ${benchmark_test_path}/libhiai_ir.so || exit 1 cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -1961,7 +1959,6 @@ function Run_arm64_fp16() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -2133,7 +2130,6 @@ function Run_armv82_a32_fp16() { cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir.so ${benchmark_test_path}/libhiai_ir.so || exit 1 cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -2311,7 +2307,6 @@ function Run_gpu() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -2464,7 +2459,6 @@ function Run_npu() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone diff --git a/mindspore/lite/test/st/run_net_train.sh b/mindspore/lite/test/st/run_net_train.sh index 4933bfc17fd..f54e310b345 100755 --- a/mindspore/lite/test/st/run_net_train.sh +++ b/mindspore/lite/test/st/run_net_train.sh @@ -153,7 +153,6 @@ function Run_arm() { fi cp -a ${arm_path}/mindspore-lite-${version_arm}-train-android-${process_unit}/train/lib/libmindspore-lite-train.so ${benchmark_train_test_path}/libmindspore-lite-train.so || exit 1 - cp -a ${arm_path}/mindspore-lite-${version_arm}-train-android-${process_unit}/train/lib/libmslite_kernel_reg.so ${benchmark_train_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm_path}/mindspore-lite-${version_arm}-train-android-${process_unit}/tools/benchmark_train/benchmark_train ${benchmark_train_test_path}/benchmark_train || exit 1 # adb push all needed files to the phone diff --git a/mindspore/lite/test/st/scripts/run_benchmark_arm.sh b/mindspore/lite/test/st/scripts/run_benchmark_arm.sh index 216cb72a256..fab0a6f36b3 100644 --- a/mindspore/lite/test/st/scripts/run_benchmark_arm.sh +++ b/mindspore/lite/test/st/scripts/run_benchmark_arm.sh @@ -612,7 +612,6 @@ function Run_arm64() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -1033,7 +1032,6 @@ function Run_arm32() { cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir.so ${benchmark_test_path}/libhiai_ir.so || exit 1 cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm32_path}/mindspore-lite-${version}-inference-android-aarch32/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -1091,7 +1089,6 @@ function Run_arm64_fp16() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone @@ -1263,7 +1260,6 @@ function Run_armv82_a32_fp16() { cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir.so ${benchmark_test_path}/libhiai_ir.so || exit 1 cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${armv82_path}/mindspore-lite-${version}-inference-android-aarch32/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone diff --git a/mindspore/lite/test/st/scripts/run_benchmark_gpu.sh b/mindspore/lite/test/st/scripts/run_benchmark_gpu.sh index 1bc8c9ad266..a0edf6cbfba 100644 --- a/mindspore/lite/test/st/scripts/run_benchmark_gpu.sh +++ b/mindspore/lite/test/st/scripts/run_benchmark_gpu.sh @@ -126,7 +126,6 @@ function Run_gpu() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone diff --git a/mindspore/lite/test/st/scripts/run_benchmark_npu.sh b/mindspore/lite/test/st/scripts/run_benchmark_npu.sh index 1ebe82787f2..892be5a5cf6 100644 --- a/mindspore/lite/test/st/scripts/run_benchmark_npu.sh +++ b/mindspore/lite/test/st/scripts/run_benchmark_npu.sh @@ -71,7 +71,6 @@ function Run_npu() { cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/third_party/hiai_ddk/lib/libhiai_ir_build.so ${benchmark_test_path}/libhiai_ir_build.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 - cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/inference/lib/libmslite_kernel_reg.so ${benchmark_test_path}/libmslite_kernel_reg.so || exit 1 cp -a ${arm64_path}/mindspore-lite-${version}-inference-android-aarch64/tools/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # adb push all needed files to the phone diff --git a/mindspore/lite/test/st/scripts/run_cropper.sh b/mindspore/lite/test/st/scripts/run_cropper.sh index 14c3bd117b7..5aef974b050 100644 --- a/mindspore/lite/test/st/scripts/run_cropper.sh +++ b/mindspore/lite/test/st/scripts/run_cropper.sh @@ -31,7 +31,6 @@ function Run_cropper() { cp -a ./inference/third_party/hiai_ddk/lib/libhiai_ir_build.so "${cropper_test_path}"/libhiai_ir_build.so || exit 1 cp -a ./inference/lib/libmindspore-lite.a "${cropper_test_path}"/libmindspore-lite.a || exit 1 - cp -a ./inference/lib/libmslite_kernel_reg.so "${cropper_test_path}"/libmslite_kernel_reg.so || exit 1 cp -a ./tools/benchmark/benchmark "${cropper_test_path}"/benchmark || exit 1 cp -r "${x86_path}"/mindspore-lite-${version}-inference-linux-x64/tools/cropper/ "${cropper_test_path}" || exit 1 @@ -75,7 +74,7 @@ function Run_cropper() { -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -O0 -std=c++17 -DARM64=1 -O2 -DNDEBUG -s \ -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--warn-shared-textrel \ -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,--no-whole-archive -llog -latomic -lm \ - -L "${cropper_test_path}" -lmslite_kernel_reg -lhiai -lhiai_ir -lhiai_ir_build \ + -L "${cropper_test_path}" -lhiai -lhiai_ir -lhiai_ir_build \ -shared -o libmindspore-lite.so -Wl,-soname,libmindspore-lite.so if [ $? = 0 ]; then @@ -153,4 +152,4 @@ if [[ $Run_cropper_status == 1 ]]; then fi Print_Cropper_Result -exit 0 \ No newline at end of file +exit 0 diff --git a/mindspore/lite/tools/converter/CMakeLists.txt b/mindspore/lite/tools/converter/CMakeLists.txt index 41f11134763..bc9147ef5ea 100644 --- a/mindspore/lite/tools/converter/CMakeLists.txt +++ b/mindspore/lite/tools/converter/CMakeLists.txt @@ -206,7 +206,6 @@ target_link_libraries(converter_lite PRIVATE mindspore::json mindspore::eigen -Wl,--whole-archive mindspore_core -Wl,--no-whole-archive - mslite_kernel_reg mindspore::glog mindspore::protobuf mindspore::flatbuffers diff --git a/mindspore/lite/tools/converter/anf_transform.cc b/mindspore/lite/tools/converter/anf_transform.cc index 80a863f4a98..c9f442d651c 100644 --- a/mindspore/lite/tools/converter/anf_transform.cc +++ b/mindspore/lite/tools/converter/anf_transform.cc @@ -58,7 +58,7 @@ #include "tools/optimizer/fisson/iter_node_outputs.h" #include "tools/optimizer/fisson/node_out_shapes.h" #include "tools/optimizer/parallel/parallel_pass.h" -#include "tools/converter/registry/pass_registry.h" +#include "include/registry/pass_registry.h" #include "tools/optimizer/fisson/multi_conv_split_pass.h" using std::string; diff --git a/mindspore/lite/tools/converter/converter.cc b/mindspore/lite/tools/converter/converter.cc index a59d4f7a4d5..1ebb86c62fa 100644 --- a/mindspore/lite/tools/converter/converter.cc +++ b/mindspore/lite/tools/converter/converter.cc @@ -24,7 +24,7 @@ #include "tools/anf_exporter/anf_exporter.h" #include "include/version.h" #include "src/train/train_populate_parameter.h" -#include "tools/converter/registry/model_parser_registry.h" +#include "include/registry/model_parser_registry.h" #include "src/common/dynamic_library_loader.h" #include "tools/converter/parser/parser_utils.h" #include "tools/converter/import/mindspore_importer.h" diff --git a/mindspore/lite/tools/converter/converter.h b/mindspore/lite/tools/converter/converter.h index fe6a5851d13..4d4a054325b 100644 --- a/mindspore/lite/tools/converter/converter.h +++ b/mindspore/lite/tools/converter/converter.h @@ -22,7 +22,7 @@ #include "schema/inner/model_generated.h" #include "tools/converter/graphdef_transform.h" #include "tools/converter/model_parser.h" -#include "tools/converter/registry/model_parser_registry.h" +#include "include/registry/model_parser_registry.h" #include "tools/converter/converter_flags.h" #include "tools/converter/anf_transform.h" #include "tools/converter/converter_context.h" diff --git a/mindspore/lite/tools/converter/parser/caffe/caffe_model_parser.h b/mindspore/lite/tools/converter/parser/caffe/caffe_model_parser.h index 7cd3ab4f4ad..48b0c674e11 100644 --- a/mindspore/lite/tools/converter/parser/caffe/caffe_model_parser.h +++ b/mindspore/lite/tools/converter/parser/caffe/caffe_model_parser.h @@ -22,7 +22,7 @@ #include #include #include "tools/converter/model_parser.h" -#include "tools/converter/registry/model_parser_registry.h" +#include "include/registry/model_parser_registry.h" #include "proto/caffe.pb.h" #include "ops/primitive_c.h" diff --git a/mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.h b/mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.h index bbafae98080..1303cfe8ecc 100644 --- a/mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.h +++ b/mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.h @@ -29,7 +29,7 @@ #include #include "securec/include/securec.h" #include "tools/converter/model_parser.h" -#include "tools/converter/registry/model_parser_registry.h" +#include "include/registry/model_parser_registry.h" #include "tools/converter/parser/onnx/onnx_node_parser_registry.h" #include "proto/onnx.pb.h" #include "schema/inner/model_generated.h" diff --git a/mindspore/lite/tools/converter/parser/tf/tf_model_parser.h b/mindspore/lite/tools/converter/parser/tf/tf_model_parser.h index 4f4c7a8db9d..1b99b01e8bc 100644 --- a/mindspore/lite/tools/converter/parser/tf/tf_model_parser.h +++ b/mindspore/lite/tools/converter/parser/tf/tf_model_parser.h @@ -30,7 +30,7 @@ #include "securec/include/securec.h" #include "tools/common/tensor_util.h" #include "tools/converter/model_parser.h" -#include "tools/converter/registry/model_parser_registry.h" +#include "include/registry/model_parser_registry.h" #include "ops/primitive_c.h" namespace mindspore { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h b/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h index d8d26e0487a..063074ace61 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h @@ -22,7 +22,7 @@ #include #include #include "tools/converter/model_parser.h" -#include "tools/converter/registry/model_parser_registry.h" +#include "include/registry/model_parser_registry.h" #include "tools/converter/parser/tflite/tflite_node_parser_registry.h" #include "tools/common/tensor_util.h" diff --git a/mindspore/lite/tools/converter/registry/CMakeLists.txt b/mindspore/lite/tools/converter/registry/CMakeLists.txt index a15d42ffab5..d344a8d3e51 100644 --- a/mindspore/lite/tools/converter/registry/CMakeLists.txt +++ b/mindspore/lite/tools/converter/registry/CMakeLists.txt @@ -1,10 +1,16 @@ +set(KERNEL_REG_DIR ${TOP_DIR}/mindspore/lite/src/registry) file(GLOB CONVERT_REG_SRC pass_registry.cc model_parser_registry.cc ) - -set_property(SOURCE ${CONVERT_REG_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_LITE) -add_library(mslite_converter_plugin_reg SHARED ${CONVERT_REG_SRC}) - +file(GLOB KERNEL_REG_SRC ${KERNEL_REG_DIR}/*.cc) +set(REG_SRC ${CONVERT_REG_SRC} + ${KERNEL_REG_SRC} + ${CORE_DIR}/utils/log_adapter.cc + ${CORE_DIR}/gvar/log_adapter_common.cc + ${CORE_DIR}/gvar/logging_level.cc) +set_property(SOURCE ${REG_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_LITE) +add_library(mslite_converter_plugin_reg SHARED ${REG_SRC}) +target_link_libraries(mslite_converter_plugin_reg mindspore::glog) add_dependencies(mslite_converter_plugin_reg fbs_src) add_dependencies(mslite_converter_plugin_reg fbs_inner_src) diff --git a/mindspore/lite/tools/converter/registry/model_parser_registry.cc b/mindspore/lite/tools/converter/registry/model_parser_registry.cc index 05efeb153e2..54848a4226c 100644 --- a/mindspore/lite/tools/converter/registry/model_parser_registry.cc +++ b/mindspore/lite/tools/converter/registry/model_parser_registry.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tools/converter/registry/model_parser_registry.h" +#include "include/registry/model_parser_registry.h" #include #include diff --git a/mindspore/lite/tools/converter/registry/pass_registry.cc b/mindspore/lite/tools/converter/registry/pass_registry.cc index 8a5ae8f97cd..9e3882e11a7 100644 --- a/mindspore/lite/tools/converter/registry/pass_registry.cc +++ b/mindspore/lite/tools/converter/registry/pass_registry.cc @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "tools/converter/registry/pass_registry.h" -#include +#include "include/registry/pass_registry.h" #include +#include "src/common/log_adapter.h" namespace mindspore { namespace opt { @@ -27,7 +27,7 @@ PassRegistry *PassRegistry::GetInstance() { void PassRegistry::RegPass(int position, const PassPtr &pass) { if (pass == nullptr) { - std::cout << "pass is nullptr" << std::endl; + MS_LOG(ERROR) << "pass is nullptr."; return; } auto instance = PassRegistry::GetInstance(); diff --git a/mindspore/lite/tools/cropper/build_cropper_config.sh b/mindspore/lite/tools/cropper/build_cropper_config.sh index a7cf464577a..80df47e12c3 100644 --- a/mindspore/lite/tools/cropper/build_cropper_config.sh +++ b/mindspore/lite/tools/cropper/build_cropper_config.sh @@ -106,6 +106,8 @@ getCommonFile() { cd "${MINDSPORE_HOME}" || exit 1 include_h=() while IFS='' read -r line; do include_h+=("$line"); done < <(ls mindspore/lite/include/*.h) + regist_include_h=() + while IFS='' read -r line; do regist_include_h+=("$line"); done < <(ls mindspore/lite/include/registry/*kernel*.h) src_files_h=() while IFS='' read -r line; do src_files_h+=("$line"); done < <(ls mindspore/lite/src/*.h) common_files_h=() @@ -132,7 +134,7 @@ getCommonFile() { mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/common_infer.h mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/errorcode.h ) - all_files_h=("${include_h[@]}" "${src_files_h[@]}" "${common_files_h[@]}" "${runtime_files_h[@]}" "${others_files_h[@]}") + all_files_h=("${include_h[@]}" "${regist_include_h[@]}" "${src_files_h[@]}" "${common_files_h[@]}" "${runtime_files_h[@]}" "${others_files_h[@]}") # concat regx REMOVE_LISTS_STR="${all_files_h[0]}" @@ -152,6 +154,8 @@ getCommonFile() { while IFS='' read -r line; do mindrt_files+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/core/mindrt/src/actor/*.cc) src_files=() while IFS='' read -r line; do src_files+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/*.cc) + regist_files=() + while IFS='' read -r line; do regist_files+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/registry/*.cc) common_files=() while IFS='' read -r line; do common_files+=("$line"); done < <(ls ${MINDSPORE_HOME}/mindspore/lite/src/common/*.cc) runtime_files_cc=() @@ -169,7 +173,7 @@ getCommonFile() { "${MINDSPORE_HOME}"/mindspore/core/utils/status.cc "${MINDSPORE_HOME}"/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/common_infer.c ) - all_files=("${src_files[@]}" "${common_files[@]}" "${runtime_files_cc[@]}" + all_files=("${src_files[@]}" "${regist_files[@]}" "${common_files[@]}" "${runtime_files_cc[@]}" "${runtime_files_c[@]}" "${others_files_c[@]}" "${assembly_files[@]}" "${mindrt_files[@]}" "${cxx_api_files[@]}" )