diff --git a/scripts/apply_patches.sh b/scripts/apply_patches.sh index 8e92a2121b84..177b452319a9 100755 --- a/scripts/apply_patches.sh +++ b/scripts/apply_patches.sh @@ -6,6 +6,31 @@ CDIR="$(cd "$(dirname "$0")" ; pwd -P)" XDIR=$CDIR/.. PTDIR=$XDIR/.. +TORCH_PIN="$XDIR/torch_patches/.torch_pin" +if [ -f "$TORCH_PIN" ]; then + CID=$(cat "$TORCH_PIN") + # If starts with # and it's not merged into master, fetch from origin + if [[ $CID = \#* ]]; then + PRNUM="${CID//[!0-9]/}" + set +x + MCHECK=$(git -C $PTDIR log -1000) + if [[ $MCHECK != *"Pull Request resolved: https://github.com/pytorch/pytorch/pull/$PRNUM"* ]]; then + echo "Fetching PyTorch PR #$PRNUM" + pushd "$PTDIR" + git fetch origin "pull/$PRNUM/head:$PRNUM" + git checkout "$PRNUM" + popd + fi + set -x + elif [[ "$CID" != "" ]]; then + echo 'Checking out branch $CID' + pushd "$PTDIR" + git fetch origin "$CID" + git checkout "$CID" + popd + fi +fi + python $CDIR/cond_patch.py \ $XDIR/torch_patches \ - $PTDIR + $PTDIR \ No newline at end of file diff --git a/torch_patches/README.md b/torch_patches/README.md index 694716d6b1ee..78697bc23cd6 100644 --- a/torch_patches/README.md +++ b/torch_patches/README.md @@ -1,6 +1,6 @@ # Guidelines For Patch File Names -The only files which are considered by the apply script are the ones with extension '.diff'. +Files with extension '.diff' are consider as git patches by apply script. A file for PyTorch PR _N_ needs to be named 'N.diff'. @@ -15,3 +15,17 @@ X10-optimizer.diff Patch file are alphabetically ordered, so PyTorch PR patches are always applied before the non PyTorch ones. + +There's a special file `torch_patches/.torch_pin`, which is used to coordinate landing PRs in +`pytorch/pytorch` and `pytorch/xla`. + +To test a `pytorch/xla` PR against a `pytorch/pytorch` PR or branch, +put the PR number or branch name in this file. +Example: + +``` +#32451 +# or +my_awesome_branch # (must live in `pytorch/pytorch`) +``` +