pytorch/caffe2
Chen Lai 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
..
contrib Use sum_integers and multiply_integers (#51146) 2021-02-10 18:05:45 -08:00
core use make_shared and make_unique and clean unneeded code (#51829) 2021-02-10 21:38:43 -08:00
cuda_rtc
db
distributed Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
experiments
ideep Upgrade oneDNN (mkl-dnn) to v1.7 (#47853) 2020-12-03 11:54:31 -08:00
image
mobile [PyTorch Mobile] Add continuous build config for xplat/caffe2 2020-12-09 16:58:20 -08:00
mpi Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
observers Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
onnx Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
operators Use sum_integers and multiply_integers (#51146) 2021-02-10 18:05:45 -08:00
opt use make_shared and make_unique and clean unneeded code (#51829) 2021-02-10 21:38:43 -08:00
perfkernels Support int32 indices and offsets in nn.EmbeddingBag (#46758) 2020-11-03 23:33:50 -08:00
predictor Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
proto Make RebatchingBuffer compatible with auto shape inference 2021-02-09 12:37:26 -08:00
python test_lc_1d: Increase deadline to 5 seconds (#52013) 2021-02-11 11:59:56 -08:00
quantization [p2c2] Add support for Int8FCPackWeight in model transformation 2021-01-26 16:35:23 -08:00
queue Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
serialize [package] make torch.package produce unified format (#51826) 2021-02-09 07:45:59 -08:00
sgd [caffe2 and pytorch] use new sparse adagrad JIT'ed function in fbgemm 2021-02-10 19:52:54 -08:00
share [PyTorch] Remove CAFFE2_FB_LIMITED_MOBILE_CAPABILITY (#50385) 2021-01-20 10:26:54 -08:00
test
transforms Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
utils Use sum_integers and multiply_integers (#51146) 2021-02-10 18:05:45 -08:00
video Renaming CAFFE2_API to TORCH_API (#49496) 2020-12-18 10:54:50 -08:00
.clang-format
__init__.py
c2_aten_srcs.bzl
CMakeLists.txt Add debug helper function to check target property (#52093) 2021-02-11 15:37:14 -08:00
README.md
release-notes.md
requirements.txt Remove references to typing module from setup.py (#47677) 2020-11-12 10:04:38 -08:00
VERSION_NUMBER

Caffe2

Jenkins Build Status

Caffe2 is a lightweight, modular, and scalable deep learning framework. Building on the original Caffe, Caffe2 is designed with expression, speed, and modularity in mind.

Questions and Feedback

Please use GitHub issues (https://github.com/pytorch/pytorch/issues) to ask questions, report bugs, and request new features.

Further Resources on Caffe2.ai