mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
First step towards #83775 - only `to_padded_tensor` is moved to the nested namespace for now - following the schema used for `special`, `fft`, `linalg` and other namespaces, nested functions are registered in native_functions.yaml as `nested_{function_name}` and are bound to the desired Python name in `torch/nested/__init__.py`, and the desired C++ name in `torch/csrc/api/include/torch/nested.h`. ~~**Question**: should we keep the documentation for `Tensor.to_padded_tensor` or can this deleted since it is shared by `torch.nested.to_padded_tensor`?~~ [generated nested docs](https://docs-preview.pytorch.org/84102/nested.html?highlight=nested#module-torch.nested) Differential Revision: [D39361148](https://our.internmc.facebook.com/intern/diff/D39361148) Pull Request resolved: https://github.com/pytorch/pytorch/pull/84102 Approved by: https://github.com/drisspg
105 lines
3.8 KiB
CMake
105 lines
3.8 KiB
CMake
set(TORCH_API_TEST_DIR "${TORCH_ROOT}/test/cpp/api")
|
|
set(TORCH_API_TEST_SOURCES
|
|
${TORCH_ROOT}/test/cpp/common/main.cpp
|
|
${TORCH_API_TEST_DIR}/autograd.cpp
|
|
${TORCH_API_TEST_DIR}/any.cpp
|
|
${TORCH_API_TEST_DIR}/dataloader.cpp
|
|
${TORCH_API_TEST_DIR}/enum.cpp
|
|
${TORCH_API_TEST_DIR}/expanding-array.cpp
|
|
${TORCH_API_TEST_DIR}/fft.cpp
|
|
${TORCH_API_TEST_DIR}/functional.cpp
|
|
${TORCH_API_TEST_DIR}/integration.cpp
|
|
${TORCH_API_TEST_DIR}/init.cpp
|
|
${TORCH_API_TEST_DIR}/jit.cpp
|
|
${TORCH_API_TEST_DIR}/memory.cpp
|
|
${TORCH_API_TEST_DIR}/meta_tensor.cpp
|
|
${TORCH_API_TEST_DIR}/misc.cpp
|
|
${TORCH_API_TEST_DIR}/module.cpp
|
|
${TORCH_API_TEST_DIR}/moduledict.cpp
|
|
${TORCH_API_TEST_DIR}/modulelist.cpp
|
|
${TORCH_API_TEST_DIR}/modules.cpp
|
|
${TORCH_API_TEST_DIR}/nested.cpp
|
|
${TORCH_API_TEST_DIR}/parameterdict.cpp
|
|
${TORCH_API_TEST_DIR}/parameterlist.cpp
|
|
${TORCH_API_TEST_DIR}/namespace.cpp
|
|
${TORCH_API_TEST_DIR}/nn_utils.cpp
|
|
${TORCH_API_TEST_DIR}/optim.cpp
|
|
${TORCH_API_TEST_DIR}/ordered_dict.cpp
|
|
${TORCH_API_TEST_DIR}/rnn.cpp
|
|
${TORCH_API_TEST_DIR}/sequential.cpp
|
|
${TORCH_API_TEST_DIR}/transformer.cpp
|
|
${TORCH_API_TEST_DIR}/serialize.cpp
|
|
${TORCH_API_TEST_DIR}/special.cpp
|
|
${TORCH_API_TEST_DIR}/static.cpp
|
|
${TORCH_API_TEST_DIR}/support.cpp
|
|
${TORCH_API_TEST_DIR}/tensor_cuda.cpp
|
|
${TORCH_API_TEST_DIR}/tensor_indexing.cpp
|
|
${TORCH_API_TEST_DIR}/tensor_options_cuda.cpp
|
|
${TORCH_API_TEST_DIR}/tensor_options.cpp
|
|
${TORCH_API_TEST_DIR}/tensor.cpp
|
|
${TORCH_API_TEST_DIR}/torch_include.cpp
|
|
${TORCH_API_TEST_DIR}/inference_mode.cpp
|
|
${TORCH_API_TEST_DIR}/grad_mode.cpp
|
|
${TORCH_API_TEST_DIR}/operations.cpp
|
|
)
|
|
|
|
if(USE_DEPLOY)
|
|
list(APPEND TORCH_API_TEST_SOURCES ${TORCH_API_TEST_DIR}/imethod.cpp)
|
|
endif()
|
|
|
|
if(USE_CUDA)
|
|
list(APPEND TORCH_API_TEST_SOURCES ${TORCH_API_TEST_DIR}/parallel.cpp)
|
|
endif()
|
|
|
|
add_executable(test_api ${TORCH_API_TEST_SOURCES})
|
|
target_include_directories(test_api PRIVATE ${ATen_CPU_INCLUDE})
|
|
target_link_libraries(test_api PRIVATE torch gtest)
|
|
if(NOT MSVC)
|
|
target_compile_options_if_supported(test_api -Wno-unused-variable)
|
|
endif()
|
|
|
|
if(USE_CUDA)
|
|
target_link_libraries(test_api PRIVATE
|
|
${CUDA_LIBRARIES}
|
|
${CUDA_NVRTC_LIB}
|
|
${CUDA_CUDA_LIB}
|
|
${TORCH_CUDA_LIBRARIES})
|
|
|
|
target_compile_definitions(test_api PRIVATE "USE_CUDA")
|
|
endif()
|
|
|
|
if(USE_DEPLOY)
|
|
target_link_libraries(test_api PRIVATE torch_deploy)
|
|
endif()
|
|
|
|
# Workaround for https://github.com/pytorch/pytorch/issues/40941
|
|
if(USE_OPENMP AND CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0))
|
|
# Compiling transformer.cpp or pow_test.cpp with -O2+ and both -fuse-openmp and -faligned-newout any optimization
|
|
# Fails with internal compiler error in gcc-7.5 or older
|
|
# Workaround by compiling the tests without openmp (which they are not using anyway)
|
|
set_property(TARGET test_api APPEND_STRING PROPERTY COMPILE_FLAGS "-fno-openmp")
|
|
endif()
|
|
|
|
if(NOT MSVC)
|
|
# Clang has an unfixed bug leading to spurious missing braces
|
|
# warnings, see https://bugs.llvm.org/show_bug.cgi?id=21629
|
|
target_compile_options_if_supported(test_api "-Wno-missing-braces")
|
|
# Considered to be flaky. See the discussion at
|
|
# https://github.com/pytorch/pytorch/pull/9608
|
|
target_compile_options_if_supported(test_api "-Wno-maybe-uninitialized")
|
|
# gcc gives nonsensical warnings about variadic.h
|
|
target_compile_options_if_supported(test_api "-Wno-unused-but-set-parameter")
|
|
endif()
|
|
|
|
if(INSTALL_TEST)
|
|
install(TARGETS test_api DESTINATION bin)
|
|
# Install PDB files for MSVC builds
|
|
if(MSVC AND BUILD_SHARED_LIBS)
|
|
install(FILES $<TARGET_PDB_FILE:test_api> DESTINATION bin OPTIONAL)
|
|
endif()
|
|
endif()
|
|
|
|
add_executable(parallel_benchmark ${TORCH_API_TEST_DIR}/parallel_benchmark.cpp)
|
|
target_include_directories(parallel_benchmark PRIVATE ${ATen_CPU_INCLUDE})
|
|
target_link_libraries(parallel_benchmark PRIVATE torch)
|