Skip to content

Commit 1172a10

Browse files
malfetpytorchmergebot
authored andcommitted
[Build] Do not regenerate code endlessly without XPU (#140438)
Before this change, if one builds PyTorch without XPU build process will be perpetually regenerating code because of the reference to non-existing file, that will make autograd codegened files always out of date, see part of the `ninja -d explain torch_cpu` output: ``` ninja explain: output ../torch/csrc/inductor/aoti_torch/generated/c_shim_xpu.cpp doesn't exist ninja explain: output third_party/kineto/libkineto/CMakeFiles/libkineto_defs.bzl of phony edge with no inputs doesn't exist ninja explain: third_party/kineto/libkineto/CMakeFiles/libkineto_defs.bzl is dirty ninja explain: /Users/malfet/git/pytorch/pytorch/torch/csrc/autograd/generated/Functions.cpp is dirty ``` This is a regression introduced by #139025. After this change, incremental rebuilds with no changes cause no build actions: ``` % ninja -j1 -v -d explain -n torch_cpu ninja explain: output third_party/kineto/libkineto/CMakeFiles/libkineto_defs.bzl of phony edge with no inputs doesn't exist ninja explain: third_party/kineto/libkineto/CMakeFiles/libkineto_defs.bzl is dirty ninja: no work to do. ``` Test plan: Wait for at least on XPU build to finish... Fixes #140432 Pull Request resolved: #140438 Approved by: https://github.com/kit1980, https://github.com/huydhn
1 parent 14bb49f commit 1172a10

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

caffe2/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,12 @@ set(TORCH_GENERATED_CODE
336336
${GENERATED_H_PYTHON}
337337
${GENERATED_TESTING_PYTHON}
338338
${GENERATED_CXX_TORCH_CUDA}
339-
${GENERATED_CXX_TORCH_XPU}
340339
)
341340

341+
if(USE_XPU)
342+
list(APPEND TORCH_GENERATED_CODE ${GENERATED_CXX_TORCH_XPU})
343+
endif()
344+
342345
set(GEN_PER_OPERATOR_FLAG)
343346
if(USE_PER_OPERATOR_HEADERS)
344347
list(APPEND GEN_PER_OPERATOR_FLAG "--per_operator_headers")

0 commit comments

Comments
 (0)