1set(LAZY_TEST_ROOT ${TORCH_ROOT}/test/cpp/lazy) 2 3# Build the cpp gtest binary containing the cpp-only tests. 4set(LAZY_TEST_SRCS 5 ${LAZY_TEST_ROOT}/test_backend_device.cpp 6 ${LAZY_TEST_ROOT}/test_cache.cpp 7 ${LAZY_TEST_ROOT}/test_ir.cpp 8 ${LAZY_TEST_ROOT}/test_ir_util.cpp 9 ${LAZY_TEST_ROOT}/test_misc.cpp 10 ${LAZY_TEST_ROOT}/test_permutation_util.cpp 11 ${LAZY_TEST_ROOT}/test_shape.cpp 12 ${LAZY_TEST_ROOT}/test_trie_cache.cpp 13 ${LAZY_TEST_ROOT}/test_util.cpp 14) 15if(BUILD_LAZY_TS_BACKEND) 16 list(APPEND LAZY_TEST_SRCS 17 ${LAZY_TEST_ROOT}/test_lazy_ops.cpp 18 ${LAZY_TEST_ROOT}/test_lazy_ops_util.cpp 19 ) 20endif() 21 22add_executable(test_lazy 23 ${TORCH_ROOT}/test/cpp/common/main.cpp 24 ${LAZY_TEST_SRCS} 25) 26 27# TODO temporary until we can delete the old gtest polyfills. 28target_compile_definitions(test_lazy PRIVATE USE_GTEST) 29 30set(LAZY_TEST_DEPENDENCIES torch gtest) 31 32target_link_libraries(test_lazy PRIVATE ${LAZY_TEST_DEPENDENCIES}) 33target_include_directories(test_lazy PRIVATE ${ATen_CPU_INCLUDE}) 34 35if(USE_CUDA) 36 target_compile_definitions(test_lazy PRIVATE USE_CUDA) 37elseif(USE_ROCM) 38 target_link_libraries(test_lazy PRIVATE 39 ${ROCM_HIPRTC_LIB} 40 ${PYTORCH_HIP_LIBRARIES} 41 ${TORCH_CUDA_LIBRARIES}) 42 43 target_compile_definitions(test_lazy PRIVATE USE_ROCM) 44endif() 45 46if(INSTALL_TEST) 47 install(TARGETS test_lazy DESTINATION bin) 48 # Install PDB files for MSVC builds 49 if(MSVC AND BUILD_SHARED_LIBS) 50 install(FILES $<TARGET_PDB_FILE:test_lazy> DESTINATION bin OPTIONAL) 51 endif() 52endif() 53