Skip to content

Commit 25f4b3e

Browse files
gchananfacebook-github-bot
authored andcommitted
Add simple scripts for checking if generated code changed. (pytorch#12835)
Summary: This is designed to make it easier to see how your codegen changes affected actual generated code. Limitations: A) This is NOT robust; if new directories are added that include generated files, they need to be added to tools/generated_dirs.txt. Note that subdirectories of the list are not included. B) This is particular to my workflow which I don't claim is generally applicable. Ideally we would have a script that pumped out a diff that could be attached to PRs. C) Only works on OSS and definitely won't work on windows. How to use: 1) python setup.py ... 2) tools/git_add_generated_dirs 3) Edit codegen 4) python setup.py ... 4) git diff to see changes 5) If satisfied: tools/git_reset_generated_dirs, commit, etc. If not satisfied: Go to 3) Pull Request resolved: pytorch#12835 Reviewed By: ezyang Differential Revision: D10452255 Pulled By: gchanan fbshipit-source-id: 294fc74d41d1b840c7a26d20e05efd0aff154635
1 parent 01227f3 commit 25f4b3e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

tools/generated_dirs.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
torch/csrc/autograd/generated/
2+
torch/csrc/jit/generated/
3+
build/aten/src/ATen

tools/git_add_generated_dirs.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# HOW TO USE:
4+
# 1) python setup.py ...
5+
# 2) tools/git_add_generated_dirs
6+
# 3) Edit codegen
7+
# 4) python setup.py ...
8+
# 5) git diff to see changes
9+
# 6) If satisfied: tools/git_reset_generated_dirs, commit, etc.
10+
# If not satisfied: Go to 3)
11+
12+
BASEDIR=$(dirname "$0")
13+
(< $BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git add -f

tools/git_reset_generated_dirs.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# HOW TO USE:
4+
# 1) python setup.py ...
5+
# 2) tools/git_add_generated_dirs
6+
# 3) Edit codegen
7+
# 4) python setup.py ...
8+
# 5) git diff to see changes
9+
# 6) If satisfied: tools/git_reset_generated_dirs, commit, etc.
10+
# If not satisfied: Go to 3)
11+
12+
BASEDIR=$(dirname "$0")
13+
(< $BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git reset HEAD

0 commit comments

Comments
 (0)