mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Fixes https://github.com/pytorch/pytorch/issues/52456 ## Background Provides a context manager `_hide_source_ranges()` that disables printing graph source ranges by default. It can be overridden on a per-graph basis if desired. Pull Request resolved: https://github.com/pytorch/pytorch/pull/53188 Test Plan: ``` python test/test_jit.py TestJit.test_hide_source_ranges_context_manager ``` ```python import torch torch.jit.script def foo(x): return torch.add(x, x) print(foo.graph) with torch.jit._hide_source_ranges(): print(foo.graph) # Override context manager print(foo.graph.str(print_source_ranges=True)) print(foo.graph) ``` ``` graph(%x.1 : Tensor): %3 : int = prim::Constant[value=1]() %4 : Tensor = aten::add(%x.1, %x.1, %3) # /Users/jbschlosser/misc/example.py:5:11 return (%4) graph(%x.1 : Tensor): %3 : int = prim::Constant[value=1]() %4 : Tensor = aten::add(%x.1, %x.1, %3) return (%4) graph(%x.1 : Tensor): %3 : int = prim::Constant[value=1]() %4 : Tensor = aten::add(%x.1, %x.1, %3) # /Users/jbschlosser/misc/example.py:5:11 return (%4) graph(%x.1 : Tensor): %3 : int = prim::Constant[value=1]() %4 : Tensor = aten::add(%x.1, %x.1, %3) # /Users/jbschlosser/misc/example.py:5:11 return (%4) ``` Reviewed By: walterddr, zhangguanheng66 Differential Revision: D26817070 Pulled By: jbschlosser fbshipit-source-id: e9d123452c616b0a9dda9e134ef6c2886f229d9b |
||
|---|---|---|
| .. | ||
| init.cpp | ||
| init.h | ||
| module_python.h | ||
| pybind_utils.cpp | ||
| pybind_utils.h | ||
| pybind.h | ||
| python_arg_flatten.cpp | ||
| python_arg_flatten.h | ||
| python_custom_class.cpp | ||
| python_custom_class.h | ||
| python_interpreter.cpp | ||
| python_ir.cpp | ||
| python_ir.h | ||
| python_ivalue.h | ||
| python_sugared_value.cpp | ||
| python_sugared_value.h | ||
| python_tracer.cpp | ||
| python_tracer.h | ||
| python_tree_views.cpp | ||
| python_tree_views.h | ||
| script_init.cpp | ||
| script_init.h | ||
| update_graph_executor_opt.cpp | ||
| update_graph_executor_opt.h | ||