|
| 1 | +set(TORCH_API_TEST_DIR "${TORCH_ROOT}/test/cpp/api") |
| 2 | +set(TORCH_API_TEST_SOURCES |
| 3 | + ${TORCH_API_TEST_DIR}/any.cpp |
| 4 | + ${TORCH_API_TEST_DIR}/cursor.cpp |
| 5 | + ${TORCH_API_TEST_DIR}/expanding-array.cpp |
| 6 | + ${TORCH_API_TEST_DIR}/integration.cpp |
| 7 | + ${TORCH_API_TEST_DIR}/jit.cpp |
| 8 | + ${TORCH_API_TEST_DIR}/main.cpp |
| 9 | + ${TORCH_API_TEST_DIR}/memory.cpp |
| 10 | + ${TORCH_API_TEST_DIR}/misc.cpp |
| 11 | + ${TORCH_API_TEST_DIR}/module.cpp |
| 12 | + ${TORCH_API_TEST_DIR}/modules.cpp |
| 13 | + ${TORCH_API_TEST_DIR}/optim.cpp |
| 14 | + ${TORCH_API_TEST_DIR}/ordered-dict.cpp |
| 15 | + ${TORCH_API_TEST_DIR}/rnn.cpp |
| 16 | + ${TORCH_API_TEST_DIR}/sequential.cpp |
| 17 | + ${TORCH_API_TEST_DIR}/serialize.cpp |
| 18 | + ${TORCH_API_TEST_DIR}/static.cpp |
| 19 | + ${TORCH_API_TEST_DIR}/tensor_cuda.cpp |
| 20 | + ${TORCH_API_TEST_DIR}/tensor_options_cuda.cpp |
| 21 | + ${TORCH_API_TEST_DIR}/tensor_options.cpp |
| 22 | + ${TORCH_API_TEST_DIR}/tensor.cpp |
| 23 | +) |
| 24 | + |
| 25 | +if (USE_CUDA) |
| 26 | + list(APPEND TORCH_API_TEST_SOURCES ${TORCH_API_TEST_DIR}/parallel.cpp) |
| 27 | +endif() |
| 28 | + |
| 29 | +add_executable(test_api ${TORCH_API_TEST_SOURCES}) |
| 30 | +target_include_directories(test_api PRIVATE ${ATen_CPU_INCLUDE}) |
| 31 | +target_link_libraries(test_api PRIVATE torch gtest) |
| 32 | + |
| 33 | +if (USE_CUDA) |
| 34 | + target_link_libraries(test_api PRIVATE |
| 35 | + ${CUDA_LIBRARIES} |
| 36 | + ${CUDA_NVRTC_LIB} |
| 37 | + ${CUDA_CUDA_LIB} |
| 38 | + ${TORCH_CUDA_LIBRARIES}) |
| 39 | + target_compile_definitions(test_api PRIVATE "USE_CUDA") |
| 40 | +endif() |
| 41 | + |
| 42 | +if (NOT MSVC) |
| 43 | + if (APPLE) |
| 44 | + target_compile_options(test_api PRIVATE |
| 45 | + # Clang has an unfixed bug leading to spurious missing braces |
| 46 | + # warnings, see https://bugs.llvm.org/show_bug.cgi?id=21629 |
| 47 | + -Wno-missing-braces) |
| 48 | +else() |
| 49 | + target_compile_options(test_api PRIVATE |
| 50 | + # Considered to be flaky. See the discussion at |
| 51 | + # https://github.com/pytorch/pytorch/pull/9608 |
| 52 | + -Wno-maybe-uninitialized |
| 53 | + # gcc gives nonsensical warnings about variadic.h |
| 54 | + -Wno-unused-but-set-parameter) |
| 55 | + endif() |
| 56 | +endif() |
0 commit comments