Skip to content

Commit dc74868

Browse files
orionrPenghuiCheng
authored andcommitted
Lockdown NO_TEST=1 for tests even more (pytorch#11415)
Summary: Skip torch tests as well when NO_TEST=1 environment variable is set. Also remove the separate ATen code path for not being built with Caffe2, since it will always be built with Caffe2. cc The controller you requested could not be found. Pull Request resolved: pytorch#11415 Reviewed By: soumith Differential Revision: D9758179 Pulled By: orionr fbshipit-source-id: e3e3327364fccdc57a703aeaad8c4f30452973fb
1 parent 896aaf4 commit dc74868

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

aten/src/ATen/CMakeLists.txt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -405,30 +405,32 @@ else()
405405
endif()
406406

407407
if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
408-
foreach(test_src ${ATen_CPU_TEST_SRCS})
409-
get_filename_component(test_name ${test_src} NAME_WE)
410-
add_executable(${test_name} "${test_src}")
411-
target_include_directories(
412-
${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
413-
target_include_directories(${test_name} PRIVATE ${ATen_CPU_INCLUDE})
414-
target_include_directories(${test_name} SYSTEM PRIVATE ${ATen_THIRD_PARTY_INCLUDE})
415-
target_link_libraries(${test_name} ATen_cpu)
416-
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
417-
install(TARGETS ${test_name} DESTINATION test)
418-
endforeach()
419-
420-
if(USE_CUDA OR USE_ROCM)
421-
foreach(test_src ${ATen_CUDA_TEST_SRCS})
408+
if (BUILD_TEST)
409+
foreach(test_src ${ATen_CPU_TEST_SRCS})
422410
get_filename_component(test_name ${test_src} NAME_WE)
423-
torch_cuda_based_add_executable(${test_name} "${test_src}")
411+
add_executable(${test_name} "${test_src}")
424412
target_include_directories(
425413
${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
426414
target_include_directories(${test_name} PRIVATE ${ATen_CPU_INCLUDE})
427415
target_include_directories(${test_name} SYSTEM PRIVATE ${ATen_THIRD_PARTY_INCLUDE})
428-
target_link_libraries(${test_name} -Wl,--no-as-needed ATen_cpu ATen_cuda)
416+
target_link_libraries(${test_name} ATen_cpu)
429417
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
430418
install(TARGETS ${test_name} DESTINATION test)
431419
endforeach()
420+
421+
if(USE_CUDA OR USE_ROCM)
422+
foreach(test_src ${ATen_CUDA_TEST_SRCS})
423+
get_filename_component(test_name ${test_src} NAME_WE)
424+
torch_cuda_based_add_executable(${test_name} "${test_src}")
425+
target_include_directories(
426+
${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
427+
target_include_directories(${test_name} PRIVATE ${ATen_CPU_INCLUDE})
428+
target_include_directories(${test_name} SYSTEM PRIVATE ${ATen_THIRD_PARTY_INCLUDE})
429+
target_link_libraries(${test_name} -Wl,--no-as-needed ATen_cpu ATen_cuda)
430+
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
431+
install(TARGETS ${test_name} DESTINATION test)
432+
endforeach()
433+
endif()
432434
endif()
433435

434436
# Make sure these don't get built by parent

tools/build_libtorch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
args = parser.parse_args()
1313

1414
os.environ['BUILD_TORCH'] = 'ON'
15+
os.environ['BUILD_TEST'] = 'ON'
1516
os.environ['ONNX_NAMESPACE'] = 'onnx_torch'
1617
os.environ['PYTORCH_PYTHON'] = sys.executable
1718

torch/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ else()
99
option(USE_CUDA "Use CUDA" ON)
1010
endif()
1111

12-
option(BUILD_TORCH_TEST "Build torch test binaries" ON)
12+
option(BUILD_TEST "Build torch test binaries" ON)
1313
option(TORCH_STATIC "Build libtorch.a rather than libtorch.so" OFF)
1414

1515
# TODO: Unify with version from setup.py
@@ -403,7 +403,7 @@ install(TARGETS torch
403403
ARCHIVE DESTINATION "${TORCH_INSTALL_LIB_DIR}")
404404

405405
# JIT Tests. TODO: Put into test/cpp/jit folder
406-
if (BUILD_TORCH_TEST AND NOT MSVC AND NOT APPLE AND NOT USE_ROCM)
406+
if (BUILD_TEST AND NOT MSVC AND NOT APPLE AND NOT USE_ROCM)
407407
add_executable(test_jit ${TORCH_SRC_DIR}/csrc/jit/test_jit.cpp)
408408
target_link_libraries(test_jit torch ${TORCH_CUDA_LIBRARIES})
409409
target_compile_definitions(test_jit PUBLIC USE_CATCH _FORCE_INLINES)
@@ -416,7 +416,7 @@ if (BUILD_TORCH_TEST AND NOT MSVC AND NOT APPLE AND NOT USE_ROCM)
416416
endif()
417417
endif()
418418

419-
if (BUILD_TORCH_TEST AND NOT NO_API AND NOT USE_ROCM)
419+
if (BUILD_TEST AND NOT NO_API AND NOT USE_ROCM)
420420
set(TORCH_API_TEST_DIR "${TORCH_ROOT}/test/cpp/api")
421421

422422
add_executable(test_api

0 commit comments

Comments
 (0)