Allow pre-commit hook to sync c10 headers between ET and pytorch #15184
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request enhances the workflow for updating the PyTorch commit pin by also automatically syncing the
c10directories between ExecuTorch and PyTorch. The changes update both the pre-commit hook and the update script to ensure that any time the PyTorch pin is updated, the corresponding source files inruntime/core/portable_type/c10/are checked and grafted from PyTorch if needed. This helps keep the local codebase consistent with upstream changes and reduces manual maintenance.Pre-commit hook improvements:
.githooks/pre-commitscript now triggers both the PyTorch pin update and the c10 directory sync whenevertorch_pin.pyis changed, and automatically stages any modified files for commit.Sync logic and automation:
.github/scripts/update_pytorch_pin.pyto compare files in ExecuTorch'sc10andtorch/headeronlydirectories against the corresponding PyTorch repo files at the pinned commit, and graft upstream changes when differences are detected.Dependency and import updates:
base64,hashlib,Path) to support file comparison and GitHub API interactions in the update script.