Skip to content

Commit 5c596e1

Browse files
authored
fix ncnn (#187)
1 parent 2df085c commit 5c596e1

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

csrc/backend_ops/ncnn/ops/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ include(${CMAKE_SOURCE_DIR}/cmake/MMDeploy.cmake)
77
# add plugin source
88
file(GLOB_RECURSE NCNN_OPS_SRCS *.cpp)
99
add_library(${PROJECT_NAME}_obj OBJECT "${NCNN_OPS_SRCS}")
10+
target_compile_definitions(${PROJECT_NAME}_obj PRIVATE -DMMDEPLOY_API_EXPORTS=1)
1011
set_target_properties(${PROJECT_NAME}_obj PROPERTIES POSITION_INDEPENDENT_CODE 1)
11-
target_include_directories(${PROJECT_NAME}_obj PUBLIC
12-
$<TARGET_PROPERTY:ncnn,INTERFACE_INCLUDE_DIRECTORIES>)
12+
target_link_libraries(${PROJECT_NAME}_obj PRIVATE ncnn)
1313
set(_COMMON_INCLUDE_DIRS
1414
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
1515
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/csrc>)

csrc/backend_ops/ncnn/ops/ncnn_ops_register.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
#include "core/macro.h"
99
#include "net.h"
1010

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

1514
MMDEPLOY_API int register_mmdeploy_custom_layers(ncnn::Net& net);
16-
}
1715

1816
#endif

csrc/backend_ops/ncnn/pyncnn_ext/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ endif ()
1010
pybind11_add_module(ncnn_ext ncnn_ext.cpp)
1111

1212
target_link_libraries(ncnn_ext PUBLIC mmdeploy_ncnn_ops ncnn)
13-
set_target_properties(
14-
ncnn_ext PROPERTIES LIBRARY_OUTPUT_DIRECTORY
15-
${CMAKE_SOURCE_DIR}/mmdeploy/backend/ncnn)
13+
set(_NCNN_EXT_DIR ${CMAKE_SOURCE_DIR}/mmdeploy/backend/ncnn)
14+
set_target_properties(ncnn_ext PROPERTIES
15+
LIBRARY_OUTPUT_DIRECTORY ${_NCNN_EXT_DIR}
16+
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${_NCNN_EXT_DIR}
17+
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${_NCNN_EXT_DIR})

csrc/net/ncnn/ncnn_net.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,20 @@ Result<void> NCNNNet::Init(const Value& args) {
4141

4242
input_indices_ = net_.input_indexes();
4343
for (const auto& x : net_.input_names()) {
44-
// input_names_.emplace_back(x);
4544
input_tensors_.emplace_back(TensorDesc{
46-
.device = Device("cpu"),
47-
.data_type = DataType::kFLOAT,
48-
.shape = {},
49-
.name = x,
45+
Device("cpu"),
46+
DataType::kFLOAT,
47+
{},
48+
x,
5049
});
5150
}
5251
output_indices_ = net_.output_indexes();
5352
for (const auto& x : net_.output_names()) {
54-
// output_names_.emplace_back(x);
5553
output_tensors_.emplace_back(TensorDesc{
56-
.device = Device("cpu"),
57-
.data_type = DataType::kFLOAT,
58-
.shape = {},
59-
.name = x,
54+
Device("cpu"),
55+
DataType::kFLOAT,
56+
{},
57+
x,
6058
});
6159
}
6260

mmdeploy/backend/ncnn/init_plugins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_ops_path() -> str:
1212
"""
1313
candidates = [
1414
'../../../build/lib/libmmdeploy_ncnn_ops.so',
15-
'../../../build/bin/*/mmdeploy_ncnn_ops.pyd'
15+
'../../../build/bin/*/mmdeploy_ncnn_ops.dll'
1616
]
1717
return get_file_path(os.path.dirname(__file__), candidates)
1818

@@ -24,6 +24,6 @@ def get_onnx2ncnn_path() -> str:
2424
str: A path of onnx2ncnn tool.
2525
"""
2626
candidates = [
27-
'../../../build/bin/onnx2ncnn', '../../../build/bin/*/onnx2ncnn'
27+
'../../../build/bin/onnx2ncnn', '../../../build/bin/*/onnx2ncnn.exe'
2828
]
2929
return get_file_path(os.path.dirname(__file__), candidates)

0 commit comments

Comments
 (0)