Skip to content

Commit

Permalink
fix ncnn (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzhangzz authored Feb 28, 2022
1 parent 2df085c commit 5c596e1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions csrc/backend_ops/ncnn/ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_PROPERTY:ncnn,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(${PROJECT_NAME}_obj PRIVATE ncnn)
set(_COMMON_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/csrc>)
Expand Down
2 changes: 0 additions & 2 deletions csrc/backend_ops/ncnn/ops/ncnn_ops_register.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#include "core/macro.h"
#include "net.h"

extern "C" {
MMDEPLOY_API std::map<const char*, ncnn::layer_creator_func>& get_mmdeploy_layer_creator();
MMDEPLOY_API std::map<const char*, ncnn::layer_destroyer_func>& get_mmdeploy_layer_destroyer();

MMDEPLOY_API int register_mmdeploy_custom_layers(ncnn::Net& net);
}

#endif
8 changes: 5 additions & 3 deletions csrc/backend_ops/ncnn/pyncnn_ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
18 changes: 8 additions & 10 deletions csrc/net/ncnn/ncnn_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,20 @@ Result<void> 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,
});
}

Expand Down
4 changes: 2 additions & 2 deletions mmdeploy/backend/ncnn/init_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

0 comments on commit 5c596e1

Please sign in to comment.