|
ba7a2f6513
|
Add debug helper function to check target property (#52093)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52093
# Summary
The previous debug if statement only prints the file list, but it's not clear whether the target includes the file list correctly. This function can examine the target so it's more accurate. This pr includes changes:
1. Add a file `DebugHelper.cmake` with `print_target_properties` function.
2. Replace the debug if statement `if(FALSE)` by adding magical variable `PRINT_CMAKE_DEBUG_INFO` and applying the variable accordingly.
Note: previous debug if statement output example:
```
-- CPU sources:
-- /Users/chenlai/pytorch/aten/src/ATen/BatchedFallback.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/BatchedTensorImpl.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/BatchingRegistrations.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/CPUGeneratorImpl.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/Context.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/DLConvertor.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/DynamicLibrary.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/ExpandUtils.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/LegacyTHFunctionsCPU.cpp
-- /Users/chenlai/pytorch/aten/src/ATen/MemoryOverlap.cpp
...
-- GPU sources:
-- CPU include:
-- /Users/chenlai/pytorch/build_android/caffe2/aten/src/TH
-- /Users/chenlai/pytorch/aten/src/TH
-- /Users/chenlai/pytorch/aten/src
-- /Users/chenlai/pytorch/build_android/caffe2/aten/src
...
-- GPU include:
-- /Users/chenlai/pytorch/build_android/caffe2/aten/src/TH
-- /Users/chenlai/pytorch/aten/src/TH
-- /Users/chenlai/pytorch/build_android/caffe2/aten/src/TH
-- /Users/chenlai/pytorch/aten/src/TH
```
# Test plan
Set `PRINT_CMAKE_DEBUG_INFO` to true by adding `DPRINT_CMAKE_DEBUG_INFO` in `./scripts/build_pytorch_android.sh`, run `./scripts/build_pytorch_android.sh x86`
`print_target_properties(torch)` shows
```
torch ANDROID_ARCH = x86
torch ANDROID_STL_TYPE = c++_static
torch ARCHIVE_OUTPUT_DIRECTORY = /Users/chenlai/pytorch/build_android_x86/lib
torch AUTOGEN_ORIGIN_DEPENDS = ON
torch AUTOMOC_COMPILER_PREDEFINES = ON
torch AUTOMOC_MACRO_NAMES = Q_OBJECT;Q_GADGET;Q_NAMESPACE;Q_NAMESPACE_EXPORT
torch AUTOMOC_PATH_PREFIX = OFF
torch BINARY_DIR = /Users/chenlai/pytorch/build_android_x86/caffe2
torch BINARY_DIR = /Users/chenlai/pytorch/build_android_x86/caffe2
torch BUILD_WITH_INSTALL_RPATH = FALSE
torch CXX_STANDARD = 14
torch C_STANDARD = 11
torch IMPORTED = FALSE
torch IMPORTED_GLOBAL = FALSE
torch INCLUDE_DIRECTORIES = /Users/chenlai/pytorch/build_android_x86/aten/src;/Users/chenlai/pytorch/aten/src;/Users/chenlai/pytorch/build_android_x86;/Users/chenlai/pytorch;/Users/chenlai/pytorch/third_party/XNNPACK/include;/Users/chenlai/Library/Android/sdk/ndk/21.3.6528147/sources/third_party/vulkan/src/common;/Users/chenlai/pytorch/cmake/../third_party/eigen;/Users/chenlai/pytorch/cmake/../third_party/pybind11/include
torch INCLUDE_DIRECTORIES = /Users/chenlai/pytorch/build_android_x86/aten/src;/Users/chenlai/pytorch/aten/src;/Users/chenlai/pytorch/build_android_x86;/Users/chenlai/pytorch;/Users/chenlai/pytorch/third_party/XNNPACK/include;/Users/chenlai/Library/Android/sdk/ndk/21.3.6528147/sources/third_party/vulkan/src/common;/Users/chenlai/pytorch/cmake/../third_party/eigen;/Users/chenlai/pytorch/cmake/../third_party/pybind11/include
torch INCLUDE_DIRECTORIES = /Users/chenlai/pytorch/build_android_x86/aten/src;/Users/chenlai/pytorch/aten/src;/Users/chenlai/pytorch/build_android_x86;/Users/chenlai/pytorch;/Users/chenlai/pytorch/third_party/XNNPACK/include;/Users/chenlai/Library/Android/sdk/ndk/21.3.6528147/sources/third_party/vulkan/src/common;/Users/chenlai/pytorch/cmake/../third_party/eigen;/Users/chenlai/pytorch/cmake/../third_party/pybind11/include
torch INSTALL_RPATH = $ORIGIN
torch INSTALL_RPATH_USE_LINK_PATH = TRUE
torch INTERFACE_LINK_LIBRARIES = torch_cpu_library
torch ISPC_HEADER_SUFFIX = _ispc.h
torch LIBRARY_OUTPUT_DIRECTORY = /Users/chenlai/pytorch/build_android_x86/lib
torch LINK_LIBRARIES = torch_cpu_library
torch NAME = torch
torch PCH_INSTANTIATE_TEMPLATES = ON
torch PCH_WARN_INVALID = ON
torch POSITION_INDEPENDENT_CODE = TRUE
torch RUNTIME_OUTPUT_DIRECTORY = /Users/chenlai/pytorch/build_android_x86/bin
torch SKIP_BUILD_RPATH = FALSE
torch SOURCES = /Users/chenlai/pytorch/build_android_x86/empty.cpp
torch SOURCE_DIR = /Users/chenlai/pytorch/caffe2
torch SOURCE_DIR = /Users/chenlai/pytorch/caffe2
torch TYPE = STATIC_LIBRARY
torch TYPE = STATIC_LIBRARY
torch UNITY_BUILD_BATCH_SIZE = 8
torch UNITY_BUILD_MODE = BATCH
```
Test Plan: Imported from OSS
Reviewed By: walterddr
Differential Revision: D26377725
Pulled By: cccclai
fbshipit-source-id: dbe21ad533759f33711a0ce5328205bbcd5cf0f3
|
2021-02-11 15:37:14 -08:00 |
|