Skip to content

Commit

Permalink
Add an ability to opt in only for certain CV-CUDA operators
Browse files Browse the repository at this point in the history
- adds an ability to compile only CV-CUDA files that match the
  given pattern so the user can have binary only with selected
  operators (which also reduces its size)

Signed-off-by: Janusz Lisiecki <[email protected]>
  • Loading branch information
JanuszL committed Aug 8, 2023
1 parent e4f97ee commit 5e7aa1c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/cvcuda/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
#
Expand All @@ -16,7 +16,13 @@
# cvcuda private implementation
add_subdirectory(priv)

<<<<<<< Updated upstream
add_library(cvcuda SHARED
=======
set(CV_CUDA_LIB_FILES Operator.cpp)

set(CV_CUDA_OP_FILES
>>>>>>> Stashed changes
OpBoxBlur.cpp
OpBndBox.cpp
OpBrightnessContrast.cpp
Expand Down Expand Up @@ -55,6 +61,28 @@ add_library(cvcuda SHARED
OpAdaptiveThreshold.cpp
OpRandomResizedCrop.cpp
OpGaussianNoise.cpp
<<<<<<< Updated upstream
=======
)

# filter only one that matches the patern
if (NOT CV_CUDA_SRC_PATERN STREQUAL "")
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
string(TOLOWER ${PATTERN} PATTERN)
foreach(FILENAME ${CV_CUDA_OP_FILES})
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
list(APPEND CV_CUDA_LIB_FILES ${FILENAME})
endif()
endforeach()
endforeach()
else()
list(APPEND CV_CUDA_LIB_FILES ${CV_CUDA_OP_FILES})
endif()

add_library(cvcuda SHARED
${CV_CUDA_LIB_FILES}
>>>>>>> Stashed changes
)

target_link_libraries(cvcuda
Expand Down
31 changes: 31 additions & 0 deletions src/cvcuda/priv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@

add_subdirectory(legacy)

<<<<<<< Updated upstream
add_library(cvcuda_priv STATIC
OpBoxBlur.cpp
=======
set(CV_CUDA_PRIV_FILES IOperator.cpp)

set(CV_CUDA_PRIV_OP_FILES OpBoxBlur.cpp
>>>>>>> Stashed changes
OpBndBox.cpp
OpBrightnessContrast.cu
OpRemap.cu
OpColorTwist.cu
OpCropFlipNormalizeReformat.cu
OpNonMaximumSuppression.cu
<<<<<<< Updated upstream
IOperator.cpp
=======
>>>>>>> Stashed changes
OpReformat.cpp
OpResize.cpp
OpCustomCrop.cpp
Expand Down Expand Up @@ -54,6 +63,28 @@ add_library(cvcuda_priv STATIC
OpAdaptiveThreshold.cpp
OpRandomResizedCrop.cpp
OpGaussianNoise.cpp
<<<<<<< Updated upstream
=======
)

# filter only one that matches the patern
if (NOT CV_CUDA_SRC_PATERN STREQUAL "")
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
string(TOLOWER ${PATTERN} PATTERN)
foreach(FILENAME ${CV_CUDA_PRIV_OP_FILES})
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
list(APPEND CV_CUDA_PRIV_FILES ${FILENAME})
endif()
endforeach()
endforeach()
else()
list(APPEND CV_CUDA_PRIV_FILES ${CV_CUDA_PRIV_OP_FILES})
endif()

add_library(cvcuda_priv STATIC
${CV_CUDA_PRIV_FILES}
>>>>>>> Stashed changes
)

target_link_libraries(cvcuda_priv
Expand Down
32 changes: 32 additions & 0 deletions src/cvcuda/priv/legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

<<<<<<< Updated upstream
add_library(cvcuda_legacy STATIC
=======
set(CV_CUDA_PRIV_LEGACY_FILES CvCudaLegacyHelpers.cpp)

set(CV_CUDA_PRIV_LEGACY_OP_FILES
>>>>>>> Stashed changes
filter_utils.cu
custom_crop.cu
reformat.cu
Expand Down Expand Up @@ -49,7 +55,10 @@ add_library(cvcuda_legacy STATIC
flip.cu
flip_or_copy_var_shape.cu
composite_var_shape.cu
<<<<<<< Updated upstream
CvCudaLegacyHelpers.cpp
=======
>>>>>>> Stashed changes
custom_crop.cu
reformat.cu
resize.cu
Expand All @@ -73,6 +82,29 @@ add_library(cvcuda_legacy STATIC
gaussian_noise.cu
gaussian_noise_var_shape.cu
gaussian_noise_util.cu
<<<<<<< Updated upstream
=======

)

# filter only one that matches the patern
if (NOT CV_CUDA_SRC_PATERN STREQUAL "")
foreach(PATTERN ${CV_CUDA_SRC_PATERN})
string(TOLOWER ${PATTERN} PATTERN)
foreach(FILENAME ${CV_CUDA_PRIV_LEGACY_OP_FILES})
string(TOLOWER ${FILENAME} FILENAME_LOWERCASE)
if (${FILENAME_LOWERCASE} MATCHES ${PATTERN})
list(APPEND CV_CUDA_PRIV_LEGACY_FILES ${FILENAME})
endif()
endforeach()
endforeach()
else()
list(APPEND CV_CUDA_PRIV_LEGACY_FILES ${CV_CUDA_PRIV_LEGACY_OP_FILES})
endif()

add_library(cvcuda_legacy STATIC
${CV_CUDA_PRIV_LEGACY_FILES}
>>>>>>> Stashed changes
)

target_link_libraries(cvcuda_legacy
Expand Down

0 comments on commit 5e7aa1c

Please sign in to comment.