From 6f5d34a69c02d5b814eced0825fa80624a9464eb Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Thu, 15 Aug 2024 13:39:45 -0700 Subject: [PATCH] Revert #132806, #132736, #132539, #132487 Summary: X-link: https://github.com/pytorch/pytorch/pull/133570 This reverts commit 25df063f044202899ab92d6f3d77950af5de482f. This reverts commit de00c7958301ce81b9716bdef5731ed40d4d14ca. This reverts commit 419b76c4ac80c8b1c95120cd52db622333a3a688. This reverts commit bc57d5b6ff8725bbe93f0e67db72459720c750cf. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames Differential Revision: D61335013 imported-using-ghimport D61335013 Reviewed By: jansel, albanD, colinchan15 Pulled By: ezyang fbshipit-source-id: dd0432cc7cc92d90631742bd4261c7ad0fd9f19c --- .../dynamo/dynamobench/_dynamo/utils.py | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/userbenchmark/dynamo/dynamobench/_dynamo/utils.py b/userbenchmark/dynamo/dynamobench/_dynamo/utils.py index 3b5e58a5b5..2e8c13fdbf 100644 --- a/userbenchmark/dynamo/dynamobench/_dynamo/utils.py +++ b/userbenchmark/dynamo/dynamobench/_dynamo/utils.py @@ -60,7 +60,7 @@ import torch.utils._pytree as pytree from torch import fx from torch._dispatch.python import enable_python_dispatcher -from torch._guards import Source, TracingContext +from torch._guards import TracingContext from torch._subclasses.meta_utils import is_sparse_compressed from torch._utils_internal import log_compilation_event from torch.fx._utils import _format_graph_code, lazy_format_graph_code @@ -2246,7 +2246,7 @@ def tensor_static_reason_to_message(reason: TensorStaticReason): def tensor_always_has_static_shape( tensor: Union[torch.Tensor, Any], is_tensor: bool, - tensor_source: Source, + guard_source: "torch._guards.GuardSource", ) -> Tuple[bool, Optional[TensorStaticReason]]: """ Given a tensor, source, and is_tensor flag, determine if a shape should be static. @@ -2259,20 +2259,12 @@ def tensor_always_has_static_shape( Returns a tuple, where the first element is the bool of whether or not this tensor should have a static shape. The second element is a TensorStaticReason, useful for passing to tensor_static_reason_to_message if needed. """ - from .source import is_from_unspecialized_param_buffer_source - if ( - tensor_source.guard_source().is_specialized_nn_module() - # Marking the tensor attributes of nn modules static to keep the behavior same as before - # inline_inbuilt_nn_module flag was introduced. - or tensor_source.guard_source().is_unspecialized_nn_module() - ) and config.force_nn_module_property_static_shapes: + guard_source.is_specialized_nn_module() + and config.force_nn_module_property_static_shapes + ): return True, TensorStaticReason.NN_MODULE_PROPERTY - - if ( - type(tensor) is torch.nn.Parameter - or is_from_unspecialized_param_buffer_source(tensor_source) - ) and config.force_parameter_static_shapes: + if type(tensor) is torch.nn.Parameter and config.force_parameter_static_shapes: return True, TensorStaticReason.PARAMETER if not is_tensor: return True, TensorStaticReason.NOT_TENSOR