-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMakeLists and C++ files refactoring. #2446
Changes from 5 commits
fa58d9c
8e0b151
ce80bfb
2de8972
80bf45b
06e1867
6f45098
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(torchvision) | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(TORCHVISION_VERSION 0.6.0) | ||
set(TORCHVISION_VERSION 0.5.0) | ||
|
||
option(WITH_CUDA "Enable CUDA support" OFF) | ||
|
||
|
@@ -11,64 +11,70 @@ if(WITH_CUDA) | |
endif() | ||
|
||
find_package(Python3 COMPONENTS Development) | ||
|
||
find_package(Torch REQUIRED) | ||
find_package(PNG REQUIRED) | ||
|
||
# Gather source files. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of these kinds of comments, they don't add anything valuable. |
||
file(GLOB OPERATOR_SOURCES torchvision/csrc/cpu/*.cpp torchvision/csrc/*.cpp) | ||
file(GLOB MODELS_SOURCES torchvision/csrc/models/*.cpp) | ||
|
||
# Set include directories. | ||
include_directories(torchvision/cinclude/${PROJECT_NAME}) | ||
|
||
file(GLOB HEADERS torchvision/csrc/*.h) | ||
# Image extension | ||
file(GLOB IMAGE_HEADERS torchvision/csrc/cpu/image/*.h) | ||
file(GLOB IMAGE_SOURCES torchvision/csrc/cpu/image/*.cpp) | ||
file(GLOB OPERATOR_SOURCES torchvision/csrc/cpu/*.h torchvision/csrc/cpu/*.cpp ${IMAGE_HEADERS} ${IMAGE_SOURCES} ${HEADERS} torchvision/csrc/*.cpp) | ||
if(WITH_CUDA) | ||
file(GLOB OPERATOR_SOURCES ${OPERATOR_SOURCES} torchvision/csrc/cuda/*.h torchvision/csrc/cuda/*.cu) | ||
# Gather cuda source files. | ||
file(GLOB OPERATOR_CUDA_SOURCES torchvision/csrc/cuda/*.cu) | ||
list(APPEND OPERATOR_SOURCES ${OPERATOR_CUDA_SOURCES}) | ||
|
||
# Set cuda include directories. | ||
include_directories(torchvision/cinclude/${PROJECT_NAME}_cuda) | ||
endif() | ||
file(GLOB MODELS_HEADERS torchvision/csrc/models/*.h) | ||
file(GLOB MODELS_SOURCES torchvision/csrc/models/*.h torchvision/csrc/models/*.cpp) | ||
|
||
add_library(${PROJECT_NAME} SHARED ${MODELS_SOURCES} ${OPERATOR_SOURCES} ${IMAGE_SOURCES}) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE ${TORCH_LIBRARIES} ${PNG_LIBRARY} Python3::Python) | ||
# target_link_libraries(${PROJECT_NAME} PRIVATE ${PNG_LIBRARY} Python3::Python) | ||
# Add library. | ||
add_library(${PROJECT_NAME} SHARED ${MODELS_SOURCES} ${OPERATOR_SOURCES}) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE ${TORCH_LIBRARIES} Python3::Python) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_NAME TorchVision) | ||
|
||
target_include_directories(${PROJECT_NAME} INTERFACE | ||
$<BUILD_INTERFACE:${HEADERS}:${PNG_INCLUDE_DIR}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
set(TORCHVISION_CMAKECONFIG_INSTALL_DIR "share/cmake/TorchVision" CACHE STRING "install path for TorchVisionConfig.cmake") | ||
|
||
configure_package_config_file(cmake/TorchVisionConfig.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfig.cmake" | ||
INSTALL_DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR}) | ||
"${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfig.cmake" | ||
INSTALL_DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR} | ||
) | ||
|
||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfigVersion.cmake | ||
VERSION ${TORCHVISION_VERSION} | ||
COMPATIBILITY AnyNewerVersion) | ||
VERSION ${TORCHVISION_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfig.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfigVersion.cmake | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR}) | ||
${CMAKE_CURRENT_BINARY_DIR}/TorchVisionConfigVersion.cmake | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR} | ||
) | ||
|
||
# Install library. | ||
install(TARGETS ${PROJECT_NAME} | ||
EXPORT TorchVisionTargets | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
EXPORT TorchVisionTargets | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
|
||
install(EXPORT TorchVisionTargets | ||
NAMESPACE TorchVision:: | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR}) | ||
NAMESPACE TorchVision:: | ||
DESTINATION ${TORCHVISION_CMAKECONFIG_INSTALL_DIR} | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These all look like unrelated formatting changes. I'd say stick to the current style, and if you want to propose a different one do so in a different PR. |
||
|
||
# Install headers. | ||
install( | ||
DIRECTORY "torchvision/cinclude/${PROJECT_NAME}/" | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" | ||
) | ||
|
||
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) | ||
install(FILES | ||
torchvision/csrc/cpu/vision_cpu.h | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cpu) | ||
if(WITH_CUDA) | ||
install(FILES | ||
torchvision/csrc/cuda/vision_cuda.h | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/cuda) | ||
# Install cuda headers. | ||
install( | ||
DIRECTORY "torchvision/cinclude/${PROJECT_NAME}_cuda/cuda" | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" | ||
) | ||
endif() | ||
install(FILES ${MODELS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/models) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "vision_cpu.h" | ||
#include "cpu/vision_cpu.h" | ||
|
||
template <typename scalar_t> | ||
at::Tensor nms_cpu_kernel( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "inception.h" | ||
#include "models/inception.h" | ||
|
||
namespace vision { | ||
namespace models { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like an unwanted change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry for the typo