-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·222 lines (187 loc) · 6.81 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#
# SPDX-FileCopyrightText: Copyright (c) 1993-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
add_custom_target(plugin)
set(TARGET_NAME nvinfer_plugin)
set(SHARED_TARGET ${TARGET_NAME})
set(STATIC_TARGET ${TARGET_NAME}_static)
set(TARGET_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(PLUGIN_EXPORT_MAP ${TARGET_DIR}/exports.map)
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
set(ENABLED_SMS "-DENABLE_SM72 -DENABLE_SM75 -DENABLE_SM80 -DENABLE_SM86 -DENABLE_SM87 -DENABLE_SM89 -DENABLE_SM90")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ENABLED_SMS}")
set(PLUGIN_SOURCES)
set(PLUGIN_CU_SOURCES)
set(PLUGIN_LISTS
batchedNMSLandmarkPlugin
batchedNMSLandmarkConfPlugin
batchTilePlugin
batchedNMSPlugin
clipPlugin
coordConvACPlugin
cropAndResizePlugin
decodeBbox3DPlugin
detectionLayerPlugin
disentangledAttentionPlugin
efficientNMSPlugin
efficientNMSPlugin/tftrt
efficientNMSCustomPlugin
efficientNMSLandmarkPlugin
flattenConcat
generateDetectionPlugin
gridAnchorPlugin
groupNormalizationPlugin
instanceNormalizationPlugin
leakyReluPlugin
multilevelCropAndResizePlugin
multilevelProposeROI
multiscaleDeformableAttnPlugin
nmsPlugin
normalizePlugin
nvFasterRCNN
pillarScatterPlugin
priorBoxPlugin
proposalLayerPlugin
proposalPlugin
pyramidROIAlignPlugin
regionPlugin
reorgPlugin
resizeNearestPlugin
roiAlignPlugin
roIAlign2Plugin
scatterPlugin
specialSlicePlugin
splitPlugin
voxelGeneratorPlugin
)
# Add BERT sources if ${BERT_GENCODES} was populated
if(BERT_GENCODES)
set(BERT_CU_SOURCES)
set(PLUGIN_LISTS
${PLUGIN_LISTS}
bertQKVToContextPlugin
embLayerNormPlugin
fcPlugin
geluPlugin
skipLayerNormPlugin
)
include_directories(bertQKVToContextPlugin/fused_multihead_attention/include bertQKVToContextPlugin/fused_multihead_attention_v2/include)
endif()
# Add Stable Diffusion sources if ${STABLE_DIFFUSION_GENCODES} was populated
if(STABLE_DIFFUSION_GENCODES)
set(STABLE_DIFFUSION_CU_SOURCES)
set(PLUGIN_LISTS
${PLUGIN_LISTS}
groupNormPlugin
layerNormPlugin
seqLen2SpatialPlugin
splitGeLUPlugin
multiHeadFlashAttentionPlugin
multiHeadCrossAttentionPlugin
)
include_directories(multiHeadFlashAttentionPlugin/fmha_flash_attention/include/)
include_directories(multiHeadCrossAttentionPlugin/fmha_cross_attention/include/)
endif()
include_directories(common common/kernels ${CMAKE_SOURCE_DIR}/third_party)
foreach(PLUGIN_ITER ${PLUGIN_LISTS})
include_directories(${PLUGIN_ITER})
add_subdirectory(${PLUGIN_ITER})
endforeach(PLUGIN_ITER)
# Add common
add_subdirectory(common)
# Set gencodes
set_source_files_properties(${PLUGIN_CU_SOURCES} PROPERTIES COMPILE_FLAGS "${GENCODES} ${ENABLED_SMS}")
list(APPEND PLUGIN_SOURCES "${PLUGIN_CU_SOURCES}")
if (BERT_CU_SOURCES)
set_source_files_properties(${BERT_CU_SOURCES} PROPERTIES COMPILE_FLAGS "${BERT_GENCODES} ${ENABLED_SMS}")
list(APPEND PLUGIN_SOURCES "${BERT_CU_SOURCES}")
endif()
if (STABLE_DIFFUSION_CU_SOURCES)
set_source_files_properties(${STABLE_DIFFUSION_CU_SOURCES} PROPERTIES COMPILE_FLAGS "${STABLE_DIFFUSION_GENCODES} ${ENABLED_SMS}")
list(APPEND PLUGIN_SOURCES "${STABLE_DIFFUSION_CU_SOURCES}")
endif()
list(APPEND PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/api/InferPlugin.cpp")
list(APPEND PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../samples/common/logger.cpp")
################################## SHARED LIBRARY #######################################
add_library(${SHARED_TARGET} SHARED
${PLUGIN_SOURCES}
)
target_include_directories(${SHARED_TARGET}
PUBLIC ${PROJECT_SOURCE_DIR}/include
PRIVATE ${PROJECT_SOURCE_DIR}/common
PUBLIC ${CUDA_INSTALL_DIR}/include
PRIVATE ${TARGET_DIR}
)
if (CUDA_VERSION VERSION_LESS 11.0)
target_include_directories(${SHARED_TARGET} PUBLIC ${CUB_ROOT_DIR})
endif()
set_target_properties(${SHARED_TARGET} PROPERTIES
CXX_STANDARD "14"
CXX_STANDARD_REQUIRED "YES"
CXX_EXTENSIONS "NO"
ARCHIVE_OUTPUT_DIRECTORY "${TRT_OUT_DIR}"
LIBRARY_OUTPUT_DIRECTORY "${TRT_OUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${TRT_OUT_DIR}"
)
set_target_properties(${SHARED_TARGET} PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL -Wl,--version-script=${PLUGIN_EXPORT_MAP} -Wl,--no-undefined")
set_target_properties(${SHARED_TARGET} PROPERTIES DEBUG_POSTFIX ${TRT_DEBUG_POSTFIX})
set_target_properties(${SHARED_TARGET} PROPERTIES VERSION ${TRT_VERSION} SOVERSION ${TRT_SOVERSION} )
set_property(TARGET ${SHARED_TARGET} PROPERTY CUDA_STANDARD 14)
target_link_libraries(${SHARED_TARGET}
${CUBLAS_LIB}
${CUBLASLT_LIB}
${CUDART_LIB}
${CUDNN_LIB}
${nvinfer_LIB_PATH}
${CMAKE_DL_LIBS}
)
# Needed when static linking CUDART
if (NOT MSVC)
target_link_libraries(${SHARED_TARGET} Threads::Threads ${RT_LIB})
endif()
################################## STATIC LIBRARY #######################################
add_library(${STATIC_TARGET} STATIC
${PLUGIN_SOURCES}
)
target_include_directories(${STATIC_TARGET}
PUBLIC ${PROJECT_SOURCE_DIR}/include
PUBLIC ${CUB_ROOT_DIR}
PRIVATE ${PROJECT_SOURCE_DIR}/common
PUBLIC ${CUDA_INSTALL_DIR}/include
PRIVATE ${TARGET_DIR}
)
set_target_properties(${STATIC_TARGET} PROPERTIES
CXX_STANDARD "14"
CXX_STANDARD_REQUIRED "YES"
CXX_EXTENSIONS "NO"
ARCHIVE_OUTPUT_DIRECTORY "${TRT_OUT_DIR}"
LIBRARY_OUTPUT_DIRECTORY "${TRT_OUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${TRT_OUT_DIR}"
)
set_target_properties(${STATIC_TARGET} PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL")
set_target_properties(${STATIC_TARGET} PROPERTIES DEBUG_POSTFIX ${TRT_DEBUG_POSTFIX})
set_target_properties(${STATIC_TARGET} PROPERTIES VERSION ${TRT_VERSION} SOVERSION ${TRT_SOVERSION} )
set_property(TARGET ${STATIC_TARGET} PROPERTY CUDA_STANDARD 14)
#########################################################################################
add_dependencies(plugin ${SHARED_TARGET} ${STATIC_TARGET})
################################### INSTALLATION ########################################
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)