Skip to content

Commit 36124f6

Browse files
lvhan028lzhangzzgrimoire
authored
Merge sdk (open-mmlab#251)
* check in cmake * move backend_ops to csrc/backend_ops * check in preprocess, model, some codebase and their c-apis * check in CMakeLists.txt * check in parts of test_csrc * commit everything else * add readme * update core's BUILD_INTERFACE directory * skip codespell on third_party * update trt_net and ort_net's CMakeLists * ignore clion's build directory * check in pybind11 * add onnx.proto. Remove MMDeploy's dependency on ncnn's source code * export MMDeployTargets only when MMDEPLOY_BUILD_SDK is ON * remove useless message * target include directory is wrong * change target name from mmdeploy_ppl_net to mmdeploy_pplnn_net * skip install directory * update project's cmake * remove useless code * set CMAKE_BUILD_TYPE to Release by force if it isn't set by user * update custom ops CMakeLists * pass object target's source lists * fix lint end-of-file * fix lint: trailing whitespace * fix codespell hook * remove bicubic_interpolate to csrc/backend_ops/ * set MMDEPLOY_BUILD_SDK OFF * change custom ops build command * add spdlog installation command * update docs on how to checkout pybind11 * move bicubic_interpolate to backend_ops/tensorrt directory * remove useless code * correct cmake * fix typo * fix typo * fix install directory * correct sdk's readme * set cub dir when cuda version < 11.0 * change directory where clang-format will apply to * fix build command * add .clang-format * change clang-format style from google to file * reformat csrc/backend_ops * format sdk's code * turn off clang-format for some files * add -Xcompiler=-fno-gnu-unique * fix trt topk initialize * check in config for sdk demo * update cmake script and csrc's readme * correct config's path * add cuda include directory, otherwise compile failed in case of tensorrt8.2 * clang-format onnx2ncnn.cpp Co-authored-by: zhangli <[email protected]> Co-authored-by: grimoire <[email protected]>
1 parent eceeaf0 commit 36124f6

File tree

342 files changed

+82677
-3017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+82677
-3017
lines changed

.clang-format

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveMacros: false
7+
AlignConsecutiveAssignments: false
8+
AlignConsecutiveDeclarations: false
9+
AlignEscapedNewlines: Left
10+
AlignOperands: true
11+
AlignTrailingComments: true
12+
AllowAllArgumentsOnNextLine: true
13+
AllowAllConstructorInitializersOnNextLine: true
14+
AllowAllParametersOfDeclarationOnNextLine: true
15+
AllowShortBlocksOnASingleLine: false
16+
AllowShortCaseLabelsOnASingleLine: false
17+
AllowShortFunctionsOnASingleLine: All
18+
AllowShortLambdasOnASingleLine: All
19+
AllowShortIfStatementsOnASingleLine: WithoutElse
20+
AllowShortLoopsOnASingleLine: true
21+
AlwaysBreakAfterDefinitionReturnType: None
22+
AlwaysBreakAfterReturnType: None
23+
AlwaysBreakBeforeMultilineStrings: true
24+
AlwaysBreakTemplateDeclarations: Yes
25+
BinPackArguments: true
26+
BinPackParameters: true
27+
BraceWrapping:
28+
AfterCaseLabel: false
29+
AfterClass: false
30+
AfterControlStatement: false
31+
AfterEnum: false
32+
AfterFunction: false
33+
AfterNamespace: false
34+
AfterObjCDeclaration: false
35+
AfterStruct: false
36+
AfterUnion: false
37+
AfterExternBlock: false
38+
BeforeCatch: false
39+
BeforeElse: false
40+
IndentBraces: false
41+
SplitEmptyFunction: true
42+
SplitEmptyRecord: true
43+
SplitEmptyNamespace: true
44+
BreakBeforeBinaryOperators: None
45+
BreakBeforeBraces: Attach
46+
BreakBeforeInheritanceComma: false
47+
BreakInheritanceList: BeforeColon
48+
BreakBeforeTernaryOperators: true
49+
BreakConstructorInitializersBeforeComma: false
50+
BreakConstructorInitializers: BeforeColon
51+
BreakAfterJavaFieldAnnotations: false
52+
BreakStringLiterals: true
53+
ColumnLimit: 100
54+
CommentPragmas: '^ IWYU pragma:'
55+
CompactNamespaces: false
56+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
57+
ConstructorInitializerIndentWidth: 4
58+
ContinuationIndentWidth: 4
59+
Cpp11BracedListStyle: true
60+
DerivePointerAlignment: true
61+
DisableFormat: false
62+
ExperimentalAutoDetectBinPacking: false
63+
FixNamespaceComments: true
64+
ForEachMacros:
65+
- foreach
66+
- Q_FOREACH
67+
- BOOST_FOREACH
68+
IncludeBlocks: Regroup
69+
IncludeCategories:
70+
- Regex: '^<ext/.*\.h>'
71+
Priority: 2
72+
- Regex: '^<.*\.h>'
73+
Priority: 1
74+
- Regex: '^<.*'
75+
Priority: 2
76+
- Regex: '.*'
77+
Priority: 3
78+
IncludeIsMainRegex: '([-_](test|unittest))?$'
79+
IndentCaseLabels: true
80+
IndentPPDirectives: None
81+
IndentWidth: 2
82+
IndentWrappedFunctionNames: false
83+
JavaScriptQuotes: Leave
84+
JavaScriptWrapImports: true
85+
KeepEmptyLinesAtTheStartOfBlocks: false
86+
MacroBlockBegin: ''
87+
MacroBlockEnd: ''
88+
MaxEmptyLinesToKeep: 1
89+
NamespaceIndentation: None
90+
ObjCBinPackProtocolList: Never
91+
ObjCBlockIndentWidth: 2
92+
ObjCSpaceAfterProperty: false
93+
ObjCSpaceBeforeProtocolList: true
94+
PenaltyBreakAssignment: 2
95+
PenaltyBreakBeforeFirstCallParameter: 1
96+
PenaltyBreakComment: 300
97+
PenaltyBreakFirstLessLess: 120
98+
PenaltyBreakString: 1000
99+
PenaltyBreakTemplateDeclaration: 10
100+
PenaltyExcessCharacter: 1000000
101+
PenaltyReturnTypeOnItsOwnLine: 200
102+
PointerAlignment: Left
103+
RawStringFormats:
104+
- Language: Cpp
105+
Delimiters:
106+
- cc
107+
- CC
108+
- cpp
109+
- Cpp
110+
- CPP
111+
- 'c++'
112+
- 'C++'
113+
CanonicalDelimiter: ''
114+
BasedOnStyle: google
115+
- Language: TextProto
116+
Delimiters:
117+
- pb
118+
- PB
119+
- proto
120+
- PROTO
121+
EnclosingFunctions:
122+
- EqualsProto
123+
- EquivToProto
124+
- PARSE_PARTIAL_TEXT_PROTO
125+
- PARSE_TEST_PROTO
126+
- PARSE_TEXT_PROTO
127+
- ParseTextOrDie
128+
- ParseTextProtoOrDie
129+
CanonicalDelimiter: ''
130+
BasedOnStyle: google
131+
ReflowComments: true
132+
SortIncludes: true
133+
SortUsingDeclarations: true
134+
SpaceAfterCStyleCast: false
135+
SpaceAfterLogicalNot: false
136+
SpaceAfterTemplateKeyword: true
137+
SpaceBeforeAssignmentOperators: true
138+
SpaceBeforeCpp11BracedList: false
139+
SpaceBeforeCtorInitializerColon: true
140+
SpaceBeforeInheritanceColon: true
141+
SpaceBeforeParens: ControlStatements
142+
SpaceBeforeRangeBasedForLoopColon: true
143+
SpaceInEmptyParentheses: false
144+
SpacesBeforeTrailingComments: 2
145+
SpacesInAngles: false
146+
SpacesInContainerLiterals: true
147+
SpacesInCStyleCastParentheses: false
148+
SpacesInParentheses: false
149+
SpacesInSquareBrackets: false
150+
Standard: Auto
151+
StatementMacros:
152+
- Q_UNUSED
153+
- QT_REQUIRE_VERSION
154+
TabWidth: 8
155+
UseTab: Never
156+
...

.github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
- name: Format c/cuda codes with clang-format
2525
uses: DoozyX/[email protected]
2626
with:
27-
source: backend_ops
27+
source: csrc
2828
extensions: h,c,cpp,hpp,cu,cuh
29-
style: google
29+
style: file
3030
- name: Check docstring coverage
3131
run: |
3232
pip install interrogate

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,10 @@ work_dirs/
121121
*.pth
122122
*.py~
123123
*.sh~
124+
125+
#clion's build directory
126+
/cmake-build-debug
127+
/cmake-build-release
128+
129+
# install directory
130+
/install

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "third_party/cub"]
22
path = third_party/cub
33
url = https://github.com/NVIDIA/cub.git
4+
[submodule "third_party/pybind11"]
5+
path = third_party/pybind11
6+
url = https://github.com/pybind/pybind11.git

.pre-commit-config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ repos:
4343
rev: v2.1.0
4444
hooks:
4545
- id: codespell
46+
args: ["--skip=third_party/*,*.proto"]
47+
4648
- repo: https://github.com/myint/docformatter
4749
rev: v1.3.1
4850
hooks:

CMakeLists.txt

+83-42
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,84 @@
1+
# Copyright (c) OpenMMLab. All rights reserved.
2+
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
3+
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "MMDeploy's installation directory")
4+
endif ()
5+
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
6+
17
cmake_minimum_required(VERSION 3.14)
2-
project(mmdeploy_backend_ops)
3-
4-
# ONNXRUNTIME config
5-
6-
# enable onnxruntime
7-
option(BUILD_ONNXRUNTIME_OPS "enable ONNXRUNTIME ops" OFF)
8-
# ONNXRUNTIME search path
9-
if(BUILD_ONNXRUNTIME_OPS)
10-
if(NOT DEFINED ONNXRUNTIME_DIR)
11-
set(ONNXRUNTIME_DIR $ENV{ONNXRUNTIME_DIR})
12-
endif()
13-
if(NOT ONNXRUNTIME_DIR)
14-
message(ERROR " ONNXRUNTIME_DIR is not found.")
15-
endif()
16-
endif()
17-
18-
# TensorRT config
19-
20-
# enable tensorrt
21-
option(BUILD_TENSORRT_OPS "enable TensorRT ops" OFF)
22-
# TensorRT search path
23-
if(BUILD_TENSORRT_OPS)
24-
if(NOT DEFINED TENSORRT_DIR)
25-
set(TENSORRT_DIR $ENV{TENSORRT_DIR})
26-
endif()
27-
endif()
28-
29-
# NCNN config
30-
31-
# enable ncnn
32-
option(BUILD_NCNN_OPS "enable NCNN ops" OFF)
33-
# NCNN search path
34-
if(BUILD_NCNN_OPS)
35-
if(NOT DEFINED NCNN_DIR)
36-
set(NCNN_DIR $ENV{NCNN_DIR})
37-
endif()
38-
if(NOT NCNN_DIR)
39-
message(ERROR " NCNN_DIR is not found.")
40-
endif()
41-
endif()
42-
43-
add_subdirectory(backend_ops)
8+
project(MMDeploy VERSION 0.1.0)
9+
10+
set(CMAKE_CXX_STANDARD 17)
11+
12+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
13+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
14+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
15+
16+
# options
17+
option(MMDEPLOY_BUILD_MODEL_OPTIMIZER "build MMDeploy's model optimizer" ON)
18+
option(MMDEPLOY_BUILD_SDK "build MMDeploy's SDK" OFF)
19+
option(MMDEPLOY_ZIP_MODEL "support sdk model in zip format" OFF)
20+
option(MMDEPLOY_BUILD_TEST "build MMDeploy's csrc's unittest" OFF)
21+
set(MMDEPLOY_TARGET_DEVICES
22+
"cpu" CACHE STRING "MMDeploy's target devices")
23+
set(MMDEPLOY_TARGET_BACKENDS "" CACHE STRING "MMDeploy's target inference engines")
24+
set(MMDEPLOY_CODEBASES "" CACHE STRING "select OpenMMLab's codebases")
25+
#set(MMDEPLOY_TRANSFORM_PLATFORMS "cpu" CACHE STRING "select transform operations' platform")
26+
27+
if (NOT CMAKE_BUILD_TYPE)
28+
set(CMAKE_BUILD_TYPE Release CACHE STRING "choose 'Release' as default build type" FORCE)
29+
endif ()
30+
31+
include(${CMAKE_SOURCE_DIR}/cmake/common.cmake)
32+
# set INTERFACE target to gather linked modules
33+
add_library(MMDeployStaticModules INTERFACE)
34+
add_library(MMDeployDynamicModules INTERFACE)
35+
36+
add_subdirectory(csrc)
37+
if (MMDEPLOY_BUILD_TEST)
38+
add_subdirectory(tests/test_csrc)
39+
endif ()
40+
41+
if (MMDEPLOY_BUILD_SDK)
42+
# get static modules and dynamic modules from MMDeployStaticModules and MMDeployDynamicModules, respectively
43+
set(STATIC_MODULES)
44+
get_target_property(STATIC_MODULES MMDeployStaticModules INTERFACE_LINK_LIBRARIES)
45+
get_target_list("${STATIC_MODULES}" FILTERED_MODULES)
46+
set(MMDEPLOY_STATIC_MODULES "${FILTERED_MODULES}" CACHE STRING "MMDeploy's static modules")
47+
message(STATUS "MMDEPLOY_STATIC_MODULES: ${MMDEPLOY_STATIC_MODULES}")
48+
49+
set(DYNAMIC_MODULES)
50+
get_target_property(DYNAMIC_MODULES MMDeployDynamicModules INTERFACE_LINK_LIBRARIES)
51+
get_target_list("${DYNAMIC_MODULES}" FILTERED_MODULES)
52+
set(MMDEPLOY_DYNAMIC_MODULES "${FILTERED_MODULES}" CACHE STRING "MMDeploy's dynamic modules")
53+
message(STATUS "MMDEPLOY_DYNAMIC_MODULES: ${MMDEPLOY_DYNAMIC_MODULES}")
54+
55+
# export MMDeploy package
56+
install(EXPORT MMDeployTargets
57+
# NAMESPACE mmdeploy::
58+
FILE MMDeployTargets.cmake
59+
#EXPORT_LINK_INTERFACE_LIBRARIES
60+
DESTINATION lib/cmake/MMDeploy)
61+
62+
include(CMakePackageConfigHelpers)
63+
# generate the config file that is includes the exports
64+
configure_package_config_file(${CMAKE_SOURCE_DIR}/cmake/MMDeployConfig.cmake.in
65+
"${CMAKE_CURRENT_BINARY_DIR}/MMDeployConfig.cmake"
66+
INSTALL_DESTINATION "lib/cmake"
67+
NO_SET_AND_CHECK_MACRO
68+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
69+
)
70+
71+
write_basic_package_version_file(
72+
"${CMAKE_CURRENT_BINARY_DIR}/MMDeployConfigVersion.cmake"
73+
VERSION "${MMDeploy_VERSION_MAJOR}.${MMDeploy_VERSION_MINOR}"
74+
COMPATIBILITY AnyNewerVersion
75+
)
76+
77+
install(FILES
78+
${CMAKE_CURRENT_BINARY_DIR}/MMDeployConfig.cmake
79+
${CMAKE_CURRENT_BINARY_DIR}/MMDeployConfigVersion.cmake
80+
DESTINATION lib/cmake/MMDeploy
81+
)
82+
83+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/demo/csrc/ DESTINATION example)
84+
endif ()

backend_ops/CMakeLists.txt

-24
This file was deleted.

backend_ops/ncnn/onnx2ncnn/CMakeLists.txt

-14
This file was deleted.

backend_ops/ncnn/ops/CMakeLists.txt

-5
This file was deleted.

backend_ops/ncnn/pyncnn_ext/CMakeLists.txt

-14
This file was deleted.

0 commit comments

Comments
 (0)