Repository: pytorch
Issue: 1.10.0 failed to build due to missing TensorBody.h
Labels: module: build,triaged,Stale

## 🐛 Bug

Retry (incrementally) with `cmake --build .` will work, indicating it's probably a timing issue due to missed dependency.

```
7829 FAILED: caffe2/torch/CMakeFiles/aot_compiler.dir/csrc/jit/mobile/nnc/aot_compiler.cpp.o
7830 ccache /usr/bin/g++-8 -DBUILDING_TESTS -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DIDEEP_USE_MKL -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTH_BLAS_M     KL -DUSE_EXTERNAL_MZCRC -D_FILE_OFFSET_BITS=64 -Daot_compiler_EXPORTS -I/tmp/scratch/pytorch/build/aten/src -I/tmp/scratch/pytorch/aten/src -I/tmp/scratch/pytorch/build -I/tmp/scratch/pytorch -I/tmp/scratch/pytorch/cmake/../third_party/benchmark/inc     lude -I/tmp/scratch/pytorch/cmake/../third_party/cudnn_frontend/include -I/tmp/scratch/pytorch/build/caffe2/contrib/aten -I/tmp/scratch/pytorch/third_party/onnx -I/tmp/scratch/pytorch/build/third_party/onnx -I/tmp/scratch/pytorch/third_party/foxi -I     /tmp/scratch/pytorch/build/third_party/foxi -isystem /tmp/scratch/pytorch/build/third_party/gloo -isystem /tmp/scratch/pytorch/cmake/../third_party/gloo -isystem /tmp/scratch/pytorch/cmake/../third_party/googletest/googlemock/include -isystem /tmp/s     cratch/pytorch/cmake/../third_party/googletest/googletest/include -isystem /opt/intel/mkl/include -isystem /tmp/scratch/pytorch/third_party/gemmlowp -isystem /tmp/scratch/pytorch/third_party/neon2sse -isystem /tmp/scratch/pytorch/third_party/XNNPACK     /include -isystem /tmp/scratch/pytorch/third_party -isystem /usr/local/include/opencv4 -isystem /usr/local/include/eigen3 -isystem /usr/include/python3.6m -isystem /usr/local/lib/python3.6/dist-packages/numpy/core/include -isystem /tmp/scratch/pytor     ch/cmake/../third_party/pybind11/include -isystem /usr/local/cuda/include -isystem /tmp/scratch/pytorch/third_party/ideep/include -fdebug-prefix-map='/tmp/scratch'='/usr/local/src' -g1 -march=haswell -mtune=generic -fvisibility-inlines-hidden -DUSE_     PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-init     ializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=dep     recated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapp     ing-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow -DHAVE_AVX2_CPU_DEFINITION -O3 -DNDEBUG -DNDEBUG -fPIC -DCAFFE2_USE_GLOO -DCUDA_HAS_FP16=1 -DHAVE_GCC_GET_CPUID -DUSE_AVX -DUSE_AVX2 -DTH_HAVE_THREAD -std=gnu++14 -MD -MT caff     e2/torch/CMakeFiles/aot_compiler.dir/csrc/jit/mobile/nnc/aot_compiler.cpp.o -MF caffe2/torch/CMakeFiles/aot_compiler.dir/csrc/jit/mobile/nnc/aot_compiler.cpp.o.d -o caffe2/torch/CMakeFiles/aot_compiler.dir/csrc/jit/mobile/nnc/aot_compiler.cpp.o -c /     tmp/scratch/pytorch/torch/csrc/jit/mobile/nnc/aot_compiler.cpp
7831 In file included from /tmp/scratch/pytorch/aten/src/ATen/Context.h:4,
7832                  from /tmp/scratch/pytorch/aten/src/ATen/ATen.h:9,
7833                  from /tmp/scratch/pytorch/torch/csrc/jit/ir/attributes.h:2,
7834                  from /tmp/scratch/pytorch/torch/csrc/jit/ir/ir.h:3,
7835                  from /tmp/scratch/pytorch/torch/csrc/jit/mobile/nnc/aot_compiler.h:4,
7836                  from /tmp/scratch/pytorch/torch/csrc/jit/mobile/nnc/aot_compiler.cpp:1:
7837 /tmp/scratch/pytorch/aten/src/ATen/Tensor.h:3:10: fatal error: ATen/core/TensorBody.h: No such file or directory
7838  #include <ATen/core/TensorBody.h>
7839           ^~~~~~~~~~~~~~~~~~~~~~~~
7840 compilation terminated.
```

## Environment

 - PyTorch Version (e.g., 1.0): v1.10.0
 - OS (e.g., Linux): Ubuntu 18.04
 - How you installed PyTorch (`conda`, `pip`, source): source
 - Build command you used (if compiling from source): cmake+ninja+gcc8

cc @malfet @seemethere