Skip to content
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

Updated cmake files to use CMAKE_INSTALL_LIBDIR instead of AIMET_INSTALL_DIR #3333

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ cmake_minimum_required(VERSION 3.19)

project(aimet)

include(GNUInstallDirs)

include(cmake/PreparePyTorch.cmake)
include(cmake/PrepareONNX.cmake)
include(cmake/PrepareTensorFlow.cmake)
Expand All @@ -51,7 +53,7 @@ set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Boolean specifying whether compiler spe

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(AIMET_INSTALL_DIR ${CMAKE_BINARY_DIR}/staging/universal)
message(NOTICE "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX} (for install target)")

if(NOT DEFINED AIMET_PYTHONPATH)
set(AIMET_PYTHONPATH "PYTHONPATH=${CMAKE_BINARY_DIR}/artifacts" CACHE STRING "python path")
Expand Down Expand Up @@ -107,6 +109,7 @@ if (ENABLE_TORCH AND ENABLE_TENSORFLOW)
endif()

# Find Python libraries
set(Python3_FIND_VIRTUALENV "STANDARD")
find_package(Python3 COMPONENTS Interpreter Development)
message(STATUS "Found Python3: ${Python3_FOUND}, at ${Python3_LIBRARIES}")

Expand Down Expand Up @@ -243,9 +246,9 @@ endif()

# Set the packaging path (if not already set)
if(NOT DEFINED AIMET_PACKAGE_PATH)
set(AIMET_PACKAGE_PATH "\"${AIMET_INSTALL_DIR}\"")
message(STATUS "Set AIMET_PACKAGE_PATH = ${AIMET_PACKAGE_PATH}")
endif(NOT DEFINED AIMET_PACKAGE_PATH)
set(AIMET_PACKAGE_PATH ${CMAKE_INSTALL_PREFIX})
message(STATUS "Set AIMET_PACKAGE_PATH = ${AIMET_PACKAGE_PATH}")
endif()

set(remote_url_cmake_opt "-DREMOTE_URL=\"\"")

Expand Down Expand Up @@ -294,18 +297,6 @@ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Benchmarks")
add_subdirectory(Benchmarks)
endif()

# -------------------------------
# Packaging - deprecated
# -------------------------------
set(CPACK_PACKAGE_NAME "aimet")
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 1)
set(CPACK_PACKAGE_VERSION_PATCH 1)
set(CPACK_SYSTEM_NAME "build-0.0.0.0")
set(CPACK_GENERATOR "TGZ")
set(CPACK_INSTALLED_DIRECTORIES ${AIMET_INSTALL_DIR} .)
include(CPack)

# -------------------------------
# Upload pip packages
# -------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#=============================================================================

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DESTINATION ${AIMET_INSTALL_DIR}
DESTINATION .
PATTERN "CMakeFiles*" EXCLUDE
PATTERN "Makefile" EXCLUDE
PATTERN "*.cmake" EXCLUDE
Expand Down
13 changes: 5 additions & 8 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@
# @@-COPYRIGHT-END-@@
#==============================================================================

set(AIMET_EXAMPLES_DEST ${AIMET_INSTALL_DIR}/Examples)

add_custom_target(copy_examples
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/Docs_SOURCE/Examples)

#TODO Remove the OPTIONAL flag after Common Examples code gets added
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/common
DESTINATION ${AIMET_EXAMPLES_DEST}
DESTINATION Examples
OPTIONAL
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)

if (ENABLE_TORCH)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/torch
DESTINATION ${AIMET_EXAMPLES_DEST}
DESTINATION Examples
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
Expand All @@ -59,7 +57,7 @@ endif(ENABLE_TORCH)
if (ENABLE_TENSORFLOW)
#TODO Remove the OPTIONAL flag after TensorFlow Examples code gets added
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tensorflow
DESTINATION ${AIMET_EXAMPLES_DEST}
DESTINATION Examples
OPTIONAL
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
Expand All @@ -68,7 +66,6 @@ if (ENABLE_TENSORFLOW)
endif(ENABLE_TENSORFLOW)

# Create a tarball archive of the Examples code
install(CODE "execute_process(COMMAND
${CMAKE_COMMAND} -E chdir ${AIMET_INSTALL_DIR}
${CMAKE_COMMAND} -E tar cvzf ${AIMET_EXAMPLES_DEST}.tar.gz ${CMAKE_CURRENT_SOURCE_DIR}/Examples)"
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E tar cvzf ${CMAKE_INSTALL_PREFIX}/Examples.tar.gz .
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})"
)
2 changes: 1 addition & 1 deletion ModelOptimizations/DlCompression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ target_compile_options(MoDlCompression
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/DlCompression
DESTINATION ${AIMET_INSTALL_DIR}/lib/x86_64-linux-gnu/include)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/x86_64-linux-gnu/include)

if (ENABLE_TESTS)
add_subdirectory(test)
Expand Down
2 changes: 1 addition & 1 deletion ModelOptimizations/DlEqualization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ target_compile_options(MoDlEqualization
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/DlEqualization
DESTINATION ${AIMET_INSTALL_DIR}/lib/x86_64-linux-gnu/include)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/x86_64-linux-gnu/include)

if (ENABLE_TESTS)
add_subdirectory(test)
Expand Down
2 changes: 1 addition & 1 deletion ModelOptimizations/DlQuantization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ if (ENABLE_CUDA)
endif (ENABLE_CUDA)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/DlQuantization
DESTINATION ${AIMET_INSTALL_DIR}/lib/x86_64-linux-gnu/include)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/x86_64-linux-gnu/include)

if (ENABLE_TESTS)
add_subdirectory(test)
Expand Down
35 changes: 11 additions & 24 deletions ModelOptimizations/PyModelOptimizations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,18 @@ Python3_add_library(PyModelOptimizations SHARED
PyModelOptimizations.cpp
PyTensorQuantizer.cpp)

if (ENABLE_CUDA)
target_link_libraries(PyModelOptimizations
PUBLIC
stdc++
MoDlQuantization
MoDlEqualization
MoDlQuantizationCuda
MoDlCompression
target_link_libraries(PyModelOptimizations PUBLIC
MoDlQuantization
MoDlEqualization
MoDlCompression
${OPENCV_LINK_LIBRARIES}
)

if (ENABLE_CUDA)
target_link_libraries(PyModelOptimizations PUBLIC
MoDlQuantizationCuda
CUDA::cublas
${OPENCV_LINK_LIBRARIES}
z
)

else (ENABLE_CUDA)
target_link_libraries(PyModelOptimizations
PUBLIC
stdc++
MoDlQuantization
MoDlEqualization
MoDlCompression

${OPENCV_LINK_LIBRARIES}
z
)

endif (ENABLE_CUDA)

set_target_properties(PyModelOptimizations
Expand All @@ -77,7 +63,8 @@ set_target_properties(PyModelOptimizations
)

install(TARGETS PyModelOptimizations
LIBRARY DESTINATION ${AIMET_INSTALL_DIR}/lib/python/aimet_common
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python/aimet_common
)

add_custom_target(whl_prep_cp_common_PyModelOptimizations
Expand Down
3 changes: 1 addition & 2 deletions TrainingExtensions/common/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@
project(aimet_common)

if(NOT TARGET PyModelOptimizations)
set(AIMET_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
add_subdirectory("../../../../" "${CMAKE_CURRENT_BINARY_DIR}/aimet" EXCLUDE_FROM_ALL)
install(
FILES $<TARGET_FILE:PyModelOptimizations>
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
else()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION ${AIMET_INSTALL_DIR}/lib
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
Expand Down
6 changes: 4 additions & 2 deletions TrainingExtensions/onnx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ set_target_properties(OnnxCppOps PROPERTIES
)

install(TARGETS OnnxCppOps
LIBRARY DESTINATION ${AIMET_INSTALL_DIR}/lib/python/aimet_common
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python/aimet_common
)

# ----
Expand Down Expand Up @@ -110,7 +111,8 @@ set_target_properties(quant_info
)

install(TARGETS quant_info
LIBRARY DESTINATION ${AIMET_INSTALL_DIR}/lib/python/aimet_common
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python/aimet_common
)

# ----
Expand Down
8 changes: 4 additions & 4 deletions TrainingExtensions/onnx/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#=============================================================================

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION ${AIMET_INSTALL_DIR}/lib
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
4 changes: 2 additions & 2 deletions TrainingExtensions/tensorflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ endif(ENABLE_CUDA)


install(FILES $<TARGET_FILE:TrainingExtensionsTf>
DESTINATION ${AIMET_INSTALL_DIR}/lib/python/aimet_common
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python/aimet_common
)

install(DIRECTORY $<TARGET_FILE_DIR:TrainingExtensionsTf>/$<TARGET_FILE_PREFIX:TrainingExtensionsTf>$<TARGET_FILE_BASE_NAME:TrainingExtensionsTf>
DESTINATION ${AIMET_INSTALL_DIR}/lib/python/aimet_common
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python/aimet_common
)

add_custom_target(whl_prep_cp_tensorflow
Expand Down
8 changes: 4 additions & 4 deletions TrainingExtensions/tensorflow/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#=============================================================================

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION ${AIMET_INSTALL_DIR}/lib
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
4 changes: 2 additions & 2 deletions TrainingExtensions/torch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ if (ENABLE_TESTS)
endif()

install(DIRECTORY ${CMAKE_BINARY_DIR}/artifacts/aimet_common/
DESTINATION ${AIMET_INSTALL_DIR}/lib/python/aimet_common
FILES_MATCHING PATTERN "AimetTensorQuantizer*.so"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python/aimet_common
FILES_MATCHING PATTERN "AimetTensorQuantizer*.so"
)

add_custom_target(whl_prep_cp_torch
Expand Down
6 changes: 3 additions & 3 deletions TrainingExtensions/torch/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#=============================================================================

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION ${AIMET_INSTALL_DIR}/lib
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PATTERN "__pycache*" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE
)
3 changes: 2 additions & 1 deletion dobuildntest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ fi
echo "Starting AIMET build and test..."
workspaceFolder=`readlink -f ${workspaceFolder}`
buildFolder=$workspaceFolder/build
installFolder=$workspaceFolder/build/staging/universal
artifactsFolder=$buildFolder/artifacts
AIMET_TORCH_HOME=${buildFolder}/torch_pretrain_data

Expand Down Expand Up @@ -427,7 +428,7 @@ if [ $run_build -eq 1 ]; then
fi
# Do not exit on failure by default from this point forward
set +e
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ${extra_opts} ..
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=${installFolder} ${extra_opts} ..

make -j 8
check_stage $? "Build" "true"
Expand Down
Loading