Make tracing in code gen optional (#33715)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33715

Tracing codes depend on the full JIT, which is not available in lite interpreter. Use `-c pt.disable_gen_tracing=1` to turn off generating tracing part.
ghstack-source-id: 99252322

Test Plan:
```
buck build xplat/caffe2:torch -c pt.disable_gen_tracing=1
```
The tracing part of generated/VariableType_?.cpp will not be generated.

Reviewed By: smessmer

Differential Revision: D19684577

fbshipit-source-id: a1e5b80eca5e51c7bf72b5cc8f0e36c2135fabc2
This commit is contained in:
Martin Yuan
2020-03-04 08:13:41 -08:00
committed by Facebook Github Bot
parent 790274bff2
commit fdd771c90f
5 changed files with 46 additions and 19 deletions

View File

@ -25,7 +25,8 @@ def generate_code(ninja_global=None,
install_dir=None,
subset=None,
disable_autograd=False,
selected_op_list_path=None):
selected_op_list_path=None,
disable_trace = False):
# cwrap depends on pyyaml, so we can't import it earlier
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.insert(0, root)
@ -48,6 +49,7 @@ def generate_code(ninja_global=None,
autograd_gen_dir,
'tools/autograd',
disable_autograd=disable_autograd,
disable_trace = disable_trace,
)
gen_jit_dispatch(
declarations_path or DECLARATIONS_PATH,
@ -77,6 +79,12 @@ def main():
'--selected-op-list-path',
help='Path to the yaml file that contains the list of operators to include for custom build.',
)
parser.add_argument(
'--disable_gen_tracing',
default=False,
action='store_true',
help='Disable generating the tracing codes.',
)
options = parser.parse_args()
generate_code(
options.ninja_global,
@ -86,6 +94,7 @@ def main():
options.subset,
options.disable_autograd,
options.selected_op_list_path,
options.disable_gen_tracing,
)