Disable tracing for Pytorch Mobile client (#36007)

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

Tracing is not needed in Pytorch Mobile client. Disabling it has a couple of benefits:
1. It's a pre-requisite to build lite interpreter.
2. It saves the code size for full jit and Federated learning (around 600k).

Solution: use PYTORCH_DISABLE_TRACING to disable it. It's better than passing an argument to code-gen because:
1. It's a single-point change in the code template for both VariableType and VariableFactories.
2. code-gen does not handle VariableTypeManual.cpp. The macro is need there anyway.
ghstack-source-id: 101529401

Test Plan: CI

Reviewed By: ljk53

Differential Revision: D20852558

fbshipit-source-id: c28cec9f90208974acfa351ec9aec3fabbbb8aac
This commit is contained in:
Martin Yuan
2020-04-05 13:52:56 -07:00
committed by Facebook GitHub Bot
parent 66d50060eb
commit 81c8ca1e2e
4 changed files with 21 additions and 28 deletions

View File

@ -25,8 +25,7 @@ def generate_code(ninja_global=None,
install_dir=None,
subset=None,
disable_autograd=False,
selected_op_list_path=None,
disable_trace=False):
selected_op_list_path=None):
# 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)
@ -54,7 +53,6 @@ def generate_code(ninja_global=None,
autograd_gen_dir,
autograd_dir,
disable_autograd=disable_autograd,
disable_trace=disable_trace,
)
gen_jit_dispatch(
declarations_path or DECLARATIONS_PATH,
@ -84,12 +82,6 @@ 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,
@ -99,7 +91,6 @@ def main():
options.subset,
options.disable_autograd,
options.selected_op_list_path,
options.disable_gen_tracing,
)