Skip to content

Commit

Permalink
Updated CMakeLists.txt to add -DENABLE_TESTS argument at build
Browse files Browse the repository at this point in the history
Signed-off-by: Ashvin Kumar <[email protected]>
  • Loading branch information
quic-ashvkuma committed Dec 12, 2023
1 parent 80436ed commit e728c22
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 19 deletions.
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,22 @@ endif()

add_subdirectory(ThirdParty)

enable_testing()
if (NOT (DEFINED ENABLE_TESTS))
message("Test build not explicitly disabled. Enabling implicitly")
set(ENABLE_TESTS ON CACHE BOOL "")
endif(NOT (DEFINED ENABLE_TESTS))

if (ENABLE_TESTS)
message("Compiling test targets enabled")
enable_testing()
add_subdirectory(NightlyTests)
else (ENABLE_TESTS)
message("Compiling test targets disabled")
endif()

add_subdirectory(ModelOptimizations)
add_subdirectory(TrainingExtensions)
add_subdirectory(Examples)
add_subdirectory(NightlyTests)
add_subdirectory(Docs)
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Benchmarks")
add_subdirectory(Benchmarks)
Expand Down
5 changes: 4 additions & 1 deletion ModelOptimizations/DlCompression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,8 @@ 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)

add_subdirectory(test)
if (ENABLE_TESTS)
add_subdirectory(test)
endif()

whl_add_whl_prep_common_target(DlCompression)
5 changes: 4 additions & 1 deletion ModelOptimizations/DlEqualization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,8 @@ 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)

add_subdirectory(test)
if (ENABLE_TESTS)
add_subdirectory(test)
endif()

whl_add_whl_prep_common_target(DlEqualization)
5 changes: 4 additions & 1 deletion ModelOptimizations/DlQuantization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,8 @@ endif (ENABLE_CUDA)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/DlQuantization
DESTINATION ${AIMET_INSTALL_DIR}/lib/x86_64-linux-gnu/include)

add_subdirectory(test)
if (ENABLE_TESTS)
add_subdirectory(test)
endif()

whl_add_whl_prep_common_target(DlQuantization)
5 changes: 4 additions & 1 deletion TrainingExtensions/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
#==============================================================================

add_subdirectory(src/python)
add_subdirectory(test)

if (ENABLE_TESTS)
add_subdirectory(test)
endif()

add_custom_target(whl_prep_cp_common DEPENDS
whl_prep_cp_common_DlCompression
Expand Down
4 changes: 3 additions & 1 deletion TrainingExtensions/onnx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ find_path(ONNXRUNTIME_INC "onnxruntime_cxx_api.h" PATH_SUFFIXES onnxruntime_head
find_package(Eigen3 REQUIRED)

add_subdirectory(src/python)
add_subdirectory(test)

if (ENABLE_TESTS)
add_subdirectory(test)
endif()

add_library(OnnxCppOps SHARED
src/QcQuantizeOp.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,24 @@ set_target_properties(torch_custom_add PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/artifacts/aimet_common/customops"
)

find_path(ONNXRUNTIME_INC "onnxruntime_cxx_api.h" PATH_SUFFIXES onnxruntime_headers/include)
find_library(ONNXRUNTIME_LIBRARY NAMES libonnxruntime.so PATH_SUFFIXES /onnxruntime_headers/lib)
# This block attempts to find the version number of the installed onnxruntime_headers
find_path(ONNXRUNTIME_VER "VERSION_NUMBER" PATH_SUFFIXES onnxruntime_headers)
file(READ ${ONNXRUNTIME_VER}/VERSION_NUMBER VERSION_NUMBER)
string(REGEX REPLACE "([^0123456789.])" "" VERSION_NUMBER ${VERSION_NUMBER})
message(STATUS "Found onnxruntime_header version: ${VERSION_NUMBER}")

add_library(onnx_custom_add SHARED onnx_custom_add.cpp onnx_custom_add.h)
target_compile_features(onnx_custom_add PRIVATE cxx_std_14)
target_include_directories(onnx_custom_add PRIVATE ${ONNXRUNTIME_INC})
target_link_libraries(onnx_custom_add PUBLIC ${ONNXRUNTIME_LIBRARY})
set_target_properties(onnx_custom_add PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/artifacts/aimet_common/customops"
)
# Only build custom op targets if onnxruntime_headers are from >= v1.15.1
if(VERSION_NUMBER VERSION_GREATER_EQUAL "1.15.1")
find_path(ONNXRUNTIME_INC "onnxruntime_cxx_api.h" PATH_SUFFIXES onnxruntime_headers/include)
find_library(ONNXRUNTIME_LIBRARY NAMES libonnxruntime.so PATH_SUFFIXES /onnxruntime_headers/lib)

add_library(onnx_custom_add SHARED onnx_custom_add.cpp onnx_custom_add.h)
target_compile_features(onnx_custom_add PRIVATE cxx_std_14)
target_include_directories(onnx_custom_add PRIVATE ${ONNXRUNTIME_INC})
target_link_libraries(onnx_custom_add PUBLIC ${ONNXRUNTIME_LIBRARY})
set_target_properties(onnx_custom_add PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/artifacts/aimet_common/customops"
)
else()
message("onnxruntime headers must be >=v1.15.1 to build onnx customop targets. Skipping onnx custom op targets.")
endif()
5 changes: 4 additions & 1 deletion TrainingExtensions/tensorflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,7 @@ add_dependencies(whl_prep_ln whl_prep_ln_tensorflow)
whl_add_whl_action_target(tensorflow)

add_subdirectory(src/python)
add_subdirectory(test)

if (ENABLE_TESTS)
add_subdirectory(test)
endif()
5 changes: 3 additions & 2 deletions TrainingExtensions/torch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ add_subdirectory(src/python)
if (ENABLE_ONNX)
message(STATUS "ONNX is enabled, skipping Torch Unit test")
else(ENABLE_ONNX)
add_subdirectory(test)
if (ENABLE_TESTS)
add_subdirectory(test)
endif()
endif(ENABLE_ONNX)


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

0 comments on commit e728c22

Please sign in to comment.