diff --git a/csrc/backend_ops/ncnn/ops/CMakeLists.txt b/csrc/backend_ops/ncnn/ops/CMakeLists.txt index 4a4334518c..461301211a 100755 --- a/csrc/backend_ops/ncnn/ops/CMakeLists.txt +++ b/csrc/backend_ops/ncnn/ops/CMakeLists.txt @@ -7,9 +7,9 @@ include(${CMAKE_SOURCE_DIR}/cmake/MMDeploy.cmake) # add plugin source file(GLOB_RECURSE NCNN_OPS_SRCS *.cpp) add_library(${PROJECT_NAME}_obj OBJECT "${NCNN_OPS_SRCS}") +target_compile_definitions(${PROJECT_NAME}_obj PRIVATE -DMMDEPLOY_API_EXPORTS=1) set_target_properties(${PROJECT_NAME}_obj PROPERTIES POSITION_INDEPENDENT_CODE 1) -target_include_directories(${PROJECT_NAME}_obj PUBLIC - $) +target_link_libraries(${PROJECT_NAME}_obj PRIVATE ncnn) set(_COMMON_INCLUDE_DIRS $ $) diff --git a/csrc/backend_ops/ncnn/ops/ncnn_ops_register.h b/csrc/backend_ops/ncnn/ops/ncnn_ops_register.h index b265f6d4af..333f174e79 100755 --- a/csrc/backend_ops/ncnn/ops/ncnn_ops_register.h +++ b/csrc/backend_ops/ncnn/ops/ncnn_ops_register.h @@ -8,11 +8,9 @@ #include "core/macro.h" #include "net.h" -extern "C" { MMDEPLOY_API std::map& get_mmdeploy_layer_creator(); MMDEPLOY_API std::map& get_mmdeploy_layer_destroyer(); MMDEPLOY_API int register_mmdeploy_custom_layers(ncnn::Net& net); -} #endif diff --git a/csrc/backend_ops/ncnn/pyncnn_ext/CMakeLists.txt b/csrc/backend_ops/ncnn/pyncnn_ext/CMakeLists.txt index b60c91006d..c55acb488f 100755 --- a/csrc/backend_ops/ncnn/pyncnn_ext/CMakeLists.txt +++ b/csrc/backend_ops/ncnn/pyncnn_ext/CMakeLists.txt @@ -10,6 +10,8 @@ endif () pybind11_add_module(ncnn_ext ncnn_ext.cpp) target_link_libraries(ncnn_ext PUBLIC mmdeploy_ncnn_ops ncnn) -set_target_properties( - ncnn_ext PROPERTIES LIBRARY_OUTPUT_DIRECTORY - ${CMAKE_SOURCE_DIR}/mmdeploy/backend/ncnn) +set(_NCNN_EXT_DIR ${CMAKE_SOURCE_DIR}/mmdeploy/backend/ncnn) +set_target_properties(ncnn_ext PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${_NCNN_EXT_DIR} + LIBRARY_OUTPUT_DIRECTORY_DEBUG ${_NCNN_EXT_DIR} + LIBRARY_OUTPUT_DIRECTORY_RELEASE ${_NCNN_EXT_DIR}) diff --git a/csrc/net/ncnn/ncnn_net.cpp b/csrc/net/ncnn/ncnn_net.cpp index 041580d343..1a958ccfe8 100644 --- a/csrc/net/ncnn/ncnn_net.cpp +++ b/csrc/net/ncnn/ncnn_net.cpp @@ -41,22 +41,20 @@ Result NCNNNet::Init(const Value& args) { input_indices_ = net_.input_indexes(); for (const auto& x : net_.input_names()) { - // input_names_.emplace_back(x); input_tensors_.emplace_back(TensorDesc{ - .device = Device("cpu"), - .data_type = DataType::kFLOAT, - .shape = {}, - .name = x, + Device("cpu"), + DataType::kFLOAT, + {}, + x, }); } output_indices_ = net_.output_indexes(); for (const auto& x : net_.output_names()) { - // output_names_.emplace_back(x); output_tensors_.emplace_back(TensorDesc{ - .device = Device("cpu"), - .data_type = DataType::kFLOAT, - .shape = {}, - .name = x, + Device("cpu"), + DataType::kFLOAT, + {}, + x, }); } diff --git a/mmdeploy/backend/ncnn/init_plugins.py b/mmdeploy/backend/ncnn/init_plugins.py index 80cd871c53..10f9ca2655 100644 --- a/mmdeploy/backend/ncnn/init_plugins.py +++ b/mmdeploy/backend/ncnn/init_plugins.py @@ -12,7 +12,7 @@ def get_ops_path() -> str: """ candidates = [ '../../../build/lib/libmmdeploy_ncnn_ops.so', - '../../../build/bin/*/mmdeploy_ncnn_ops.pyd' + '../../../build/bin/*/mmdeploy_ncnn_ops.dll' ] return get_file_path(os.path.dirname(__file__), candidates) @@ -24,6 +24,6 @@ def get_onnx2ncnn_path() -> str: str: A path of onnx2ncnn tool. """ candidates = [ - '../../../build/bin/onnx2ncnn', '../../../build/bin/*/onnx2ncnn' + '../../../build/bin/onnx2ncnn', '../../../build/bin/*/onnx2ncnn.exe' ] return get_file_path(os.path.dirname(__file__), candidates)