From ed18a9d6f1494198ab4c32d54e596f749dc1c45b Mon Sep 17 00:00:00 2001 From: jianghui58 Date: Mon, 20 Dec 2021 11:41:45 +0800 Subject: [PATCH] add dpico atc adapter compile CI --- cmake/package_lite.cmake | 9 ++++ mindspore/lite/tools/converter/CMakeLists.txt | 7 ++- .../converter/adapter/dpico/CMakeLists.txt | 52 +++++++++---------- .../adapter/dpico/src/data_preprocessor.cc | 2 +- .../converter/adapter/dpico/src/dpico_pass.cc | 2 +- .../adapter/dpico/src/graph_split_api.h | 17 +----- .../adapter/dpico/src/om_generator.cc | 2 +- 7 files changed, 43 insertions(+), 48 deletions(-) diff --git a/cmake/package_lite.cmake b/cmake/package_lite.cmake index 4339ec8288b..4d6814478c7 100644 --- a/cmake/package_lite.cmake +++ b/cmake/package_lite.cmake @@ -535,6 +535,15 @@ else() DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) endif() + if(MSLITE_ENABLE_DPICO_ATC_ADAPTER) + install(FILES ${TOP_DIR}/mindspore/lite/build/tools/converter/adapter/dpico/libdpico_atc_adapter.so + DESTINATION ${CONVERTER_ROOT_DIR}/providers/SD3403 COMPONENT ${RUNTIME_COMPONENT_NAME}) + if(MSLITE_ENABLE_TOOLS) + install(TARGETS ${BECHCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} + COMPONENT ${RUNTIME_COMPONENT_NAME}) + endif() + endif() + if(MSLITE_ENABLE_RUNTIME_GLOG) install(DIRECTORY ${glog_LIBPATH}/../include/glog/ DESTINATION ${RUNTIME_INC_DIR}/third_party/glog COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") diff --git a/mindspore/lite/tools/converter/CMakeLists.txt b/mindspore/lite/tools/converter/CMakeLists.txt index 344ab927a8a..a7e27199ebe 100644 --- a/mindspore/lite/tools/converter/CMakeLists.txt +++ b/mindspore/lite/tools/converter/CMakeLists.txt @@ -57,6 +57,9 @@ file(GLOB_RECURSE CONVERTER_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ../optimizer/*.cc ) +if((NOT WIN32) AND MSLITE_ENABLE_DPICO_ATC_ADAPTER) + add_subdirectory(adapter/dpico) +endif() add_subdirectory(../anf_exporter anf_exporter) add_subdirectory(parser/caffe) add_subdirectory(parser/tflite) @@ -185,7 +188,9 @@ add_executable(converter_lite ${LITE_SRC} ) add_dependencies(converter_lite fbs_src fbs_inner_src) - +if((NOT WIN32) AND MSLITE_ENABLE_DPICO_ATC_ADAPTER) + add_dependencies(converter_lite dpico_atc_adapter) +endif() if(MSLITE_GPU_BACKEND STREQUAL opencl) include_directories(${SRC_DIR}/runtime/kernel/opencl) diff --git a/mindspore/lite/tools/converter/adapter/dpico/CMakeLists.txt b/mindspore/lite/tools/converter/adapter/dpico/CMakeLists.txt index c9ba5b859f1..7cd08c62c95 100644 --- a/mindspore/lite/tools/converter/adapter/dpico/CMakeLists.txt +++ b/mindspore/lite/tools/converter/adapter/dpico/CMakeLists.txt @@ -1,24 +1,24 @@ cmake_minimum_required(VERSION 3.14) project(DPICO_CONVERTER) -__download_pkg(pico_mapper - http://mindspore-repo.csi.rnd.huawei.com/mindspore/enterprise/dpico/pico_mapper_1115.tar.gz - b7c8ea7f4585cbc629b67a4a6ac1ad98) -__download_pkg(protobuf-3.9-for-dpico - http://mindspore-repo.csi.rnd.huawei.com/mindspore/enterprise/dpico/protobuf-3.9.0.tar.gz - b5c5a0ba33d301ae51a2f878c17e88be) -__download_pkg(opencv-4.2-for-dpico - http://mindspore-repo.csi.rnd.huawei.com/mindspore/enterprise/dpico/opencv-4.2.0.tar.gz - 00d2ff839f74c0314ee28acb120fff9a) -__download_pkg(proto-for-dpico - http://mindspore-repo.csi.rnd.huawei.com/mindspore/enterprise/dpico/proto1030.tar.gz - 461563613d3205045ca3008fd43aea63) +if(DEFINED ENV{HISI_SDK_PATH}) + set(SD3403_ATC_LIB_PATH $ENV{HISI_SDK_PATH}/sd3403_sdk/dpico_atc_adapter) +else() + message(FATAL_ERROR "error, HISI_SDK_PATH env not found") +endif() -set(PROTOC ${protobuf-3.9-for-dpico_SOURCE_DIR}/bin/protoc) +set(OPENCV_PATH ${SD3403_ATC_LIB_PATH}/opencv-4.2.0) +set(PROTOBUF_PATH ${SD3403_ATC_LIB_PATH}/protobuf-3.9.0) +set(PICO_PROTO_PATH ${SD3403_ATC_LIB_PATH}/pico_proto) +set(PICO_MAPPER_PATH ${SD3403_ATC_LIB_PATH}/pico_mapper) + +set(PROTOC ${PROTOBUF_PATH}/bin/protoc) +set(PROTO_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/pico_proto) +file(MAKE_DIRECTORY ${PROTO_OUTPUT_PATH}) execute_process(COMMAND - ${PROTOC} -I=${proto-for-dpico_SOURCE_DIR} --cpp_out=${proto-for-dpico_SOURCE_DIR} pico_caffe.proto) + ${PROTOC} -I=${PICO_PROTO_PATH} --cpp_out=${PROTO_OUTPUT_PATH} pico_caffe.proto) execute_process(COMMAND - ${PROTOC} -I=${TOP_DIR}/third_party/proto/onnx --cpp_out=${proto-for-dpico_SOURCE_DIR} onnx.proto) + ${PROTOC} -I=${TOP_DIR}/third_party/proto/onnx --cpp_out=${PROTO_OUTPUT_PATH} onnx.proto) file(GLOB_RECURSE DPICO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc @@ -29,15 +29,11 @@ file(GLOB_RECURSE DPICO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/mapper/*.cc ) -set(PICO_MAPPER_LIB_PATH ${pico_mapper_SOURCE_DIR}/lib CACHE STRING "dpico mapper lib path") -set(OPENCV_4.2.0_LIB_PATH ${opencv-4.2-for-dpico_SOURCE_DIR}/lib CACHE STRING "dpico opencv-4.2.0 lib path") -set(PROTOBUF_3.9.0_LIB_PATH ${protobuf-3.9-for-dpico_SOURCE_DIR}/lib CACHE STRING "dpico protobuf-3.9.0 lib path") - include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(BEFORE ${opencv-4.2-for-dpico_SOURCE_DIR}/include/opencv4) -include_directories(BEFORE ${protobuf-3.9-for-dpico_SOURCE_DIR}/include) -include_directories(${pico_mapper_SOURCE_DIR}/include) -include_directories(${proto-for-dpico_SOURCE_DIR}) +include_directories(BEFORE ${OPENCV_PATH}include/opencv4) +include_directories(BEFORE ${PROTOBUF_PATH}/include) +include_directories(${PICO_MAPPER_PATH}/include) +include_directories(${PROTO_OUTPUT_PATH}) link_directories(${pico_mapper_SOURCE_DIR}/lib) set_property(SOURCE ${DPICO_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_LITE) @@ -45,11 +41,11 @@ set_property(SOURCE ${DPICO_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=minds add_library(dpico_atc_adapter SHARED ${DPICO_SRC}) add_dependencies(dpico_atc_adapter fbs_src fbs_inner_src) target_link_libraries(dpico_atc_adapter - pico_mapper_api - ${PROTOBUF_3.9.0_LIB_PATH}/libprotobuf.so.3.9.0.0 - ${OPENCV_4.2.0_LIB_PATH}/libopencv_core.so.4.2 - ${OPENCV_4.2.0_LIB_PATH}/libopencv_imgcodecs.so.4.2 - ${OPENCV_4.2.0_LIB_PATH}/libopencv_imgproc.so.4.2 + ${PICO_MAPPER_PATH}/lib/libpico_mapper_api.so + ${PROTOBUF_PATH}/lib/libprotobuf.so.3.9.0.0 + ${OPENCV_PATH}/lib/libopencv_core.so.4.2 + ${OPENCV_PATH}/lib/libopencv_imgcodecs.so.4.2 + ${OPENCV_PATH}/lib/libopencv_imgproc.so.4.2 stdc++fs) if((NOT WIN32) AND ${CMAKE_BUILD_TYPE} STREQUAL "Release") diff --git a/mindspore/lite/tools/converter/adapter/dpico/src/data_preprocessor.cc b/mindspore/lite/tools/converter/adapter/dpico/src/data_preprocessor.cc index 6cd82ee5a1f..9f6e9ded73b 100644 --- a/mindspore/lite/tools/converter/adapter/dpico/src/data_preprocessor.cc +++ b/mindspore/lite/tools/converter/adapter/dpico/src/data_preprocessor.cc @@ -229,7 +229,7 @@ int DataPreprocessor::GenerateInputBinFromTxt(const std::string &raw_data_path, status = GenerateInputBin(preprocessed_line, op_shape, op_name); break; default: - MS_LOG(ERROR) << "unsupported data type " << TypeIdToString(type_id); + MS_LOG(ERROR) << "unsupported data type " << dpico::TypeIdToString(type_id); status = RET_ERROR; } if (status != RET_OK) { diff --git a/mindspore/lite/tools/converter/adapter/dpico/src/dpico_pass.cc b/mindspore/lite/tools/converter/adapter/dpico/src/dpico_pass.cc index c29ebc2d0b1..79e39e842f2 100644 --- a/mindspore/lite/tools/converter/adapter/dpico/src/dpico_pass.cc +++ b/mindspore/lite/tools/converter/adapter/dpico/src/dpico_pass.cc @@ -283,7 +283,7 @@ STATUS DpicoPass::MarkNodes(const api::FuncGraphPtr &func_graph) { primitive->AddAttr(kIsMapperSupported, MakeValue(is_supported)); } #ifdef Debug - PrintUnsupportedOps(); + PrintUnsupportedOps(unsupported_ops, unsupported_ops_size, func_graph); #endif return RET_OK; } diff --git a/mindspore/lite/tools/converter/adapter/dpico/src/graph_split_api.h b/mindspore/lite/tools/converter/adapter/dpico/src/graph_split_api.h index 6028bbea0ed..57ff59f49da 100644 --- a/mindspore/lite/tools/converter/adapter/dpico/src/graph_split_api.h +++ b/mindspore/lite/tools/converter/adapter/dpico/src/graph_split_api.h @@ -20,24 +20,9 @@ #include #include #include +#include "api/ir/func_graph_manager.h" namespace mindspore { -class AnfNode; -using AnfNodePtr = std::shared_ptr; -using AnfNodePtrList = std::vector; - -class CNode; -using CNodePtr = std::shared_ptr; -using CNodePtrList = std::vector; - -namespace api { -class FuncGraph; -using FuncGraphPtr = std::shared_ptr; - -class FuncGraphManager; -using FuncGraphManagerPtr = std::shared_ptr; -} // namespace api - namespace dpico { struct Subgraph; struct GraphSplitInfo; diff --git a/mindspore/lite/tools/converter/adapter/dpico/src/om_generator.cc b/mindspore/lite/tools/converter/adapter/dpico/src/om_generator.cc index 46bc7728af0..1aa8c33d387 100644 --- a/mindspore/lite/tools/converter/adapter/dpico/src/om_generator.cc +++ b/mindspore/lite/tools/converter/adapter/dpico/src/om_generator.cc @@ -127,7 +127,7 @@ std::string GetInputTypeStr(const AnfNodePtrList &subgraph_inputs, } std::string data_type; if (kMapperSupportedTypes.find(type_id) == kMapperSupportedTypes.end()) { - MS_LOG(WARNING) << node_name << "'s data type " << TypeIdToString(type_id) + MS_LOG(WARNING) << node_name << "'s data type " << dpico::TypeIdToString(type_id) << " is unsupported by dpico, will set it to FP32"; data_type = "FP32"; } else {