mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[pytorch] add script to run all codegen (#46243)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/46243 Add util script to test whether any codegen output changes. Test Plan: Imported from OSS Reviewed By: ezyang Differential Revision: D24388873 Pulled By: ljk53 fbshipit-source-id: ef9ef7fe6067df1e0c53aba725fc13b0dfd7f4c2
This commit is contained in:
parent
707d271493
commit
d95e1afad3
4 changed files with 65 additions and 2 deletions
60
.jenkins/pytorch/codegen-test.sh
Executable file
60
.jenkins/pytorch/codegen-test.sh
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script can also be used to test whether your diff changes any codegen output.
|
||||
#
|
||||
# Run it before and after your change:
|
||||
# .jenkins/pytorch/codegen-test.sh <baseline_output_dir>
|
||||
# .jenkins/pytorch/codegen-test.sh <test_output_dir>
|
||||
#
|
||||
# Then run diff to compare the generated files:
|
||||
# diff -Naur <baseline_output_dir> <test_output_dir>
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
COMPACT_JOB_NAME="${BUILD_ENVIRONMENT}"
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
|
||||
OUT="$(dirname "${BASH_SOURCE[0]}")/../../codegen_result"
|
||||
else
|
||||
OUT=$1
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
rm -rf "$OUT"
|
||||
|
||||
# aten codegen
|
||||
python -m tools.codegen.gen \
|
||||
-d "$OUT"/torch/share/ATen
|
||||
|
||||
# torch codegen
|
||||
python -m tools.setup_helpers.generate_code \
|
||||
--declarations-path "$OUT"/torch/share/ATen/Declarations.yaml \
|
||||
--install_dir "$OUT"
|
||||
|
||||
# pyi codegen
|
||||
mkdir -p "$OUT"/pyi/torch/_C
|
||||
mkdir -p "$OUT"/pyi/torch/nn
|
||||
python -m tools.pyi.gen_pyi \
|
||||
--declarations-path "$OUT"/torch/share/ATen/Declarations.yaml \
|
||||
--out "$OUT"/pyi
|
||||
|
||||
# autograd codegen (called by torch codegen but can run independently)
|
||||
python -m tools.autograd.gen_autograd \
|
||||
"$OUT"/torch/share/ATen/Declarations.yaml \
|
||||
"$OUT"/autograd \
|
||||
tools/autograd
|
||||
|
||||
# unboxing_wrappers codegen (called by torch codegen but can run independently)
|
||||
mkdir -p "$OUT"/unboxing_wrappers
|
||||
python -m tools.jit.gen_unboxing_wrappers \
|
||||
"$OUT"/torch/share/ATen/Declarations.yaml \
|
||||
"$OUT"/unboxing_wrappers \
|
||||
tools/jit/templates
|
||||
|
||||
# annotated_fn_args codegen (called by torch codegen but can run independently)
|
||||
mkdir -p "$OUT"/annotated_fn_args
|
||||
python -m tools.autograd.gen_annotated_fn_args \
|
||||
"$OUT"/torch/share/ATen/Declarations.yaml \
|
||||
"$OUT"/annotated_fn_args \
|
||||
tools/autograd
|
||||
|
|
@ -20,6 +20,7 @@ from .gen_python_functions import (
|
|||
get_py_variable_methods,
|
||||
op_name,
|
||||
)
|
||||
import argparse
|
||||
import textwrap
|
||||
from .gen_autograd import load_aten_declarations
|
||||
|
||||
|
|
|
|||
|
|
@ -302,7 +302,8 @@ def main():
|
|||
parser.add_argument('autograd', metavar='AUTOGRAD',
|
||||
help='path to autograd directory')
|
||||
args = parser.parse_args()
|
||||
gen_autograd(args.declarations, args.out, args.autograd)
|
||||
gen_autograd(args.declarations, args.out, args.autograd,
|
||||
SelectiveBuilder.get_nop_selector())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -535,7 +535,8 @@ def main():
|
|||
parser.add_argument('template_path', metavar='TEMPLATE_PATH',
|
||||
help='path to templates directory')
|
||||
args = parser.parse_args()
|
||||
gen_unboxing_wrappers(args.declarations, args.out, args.template_path)
|
||||
gen_unboxing_wrappers(args.declarations, args.out, args.template_path,
|
||||
SelectiveBuilder.get_nop_selector())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in a new issue