Skip to content

Commit

Permalink
Revert #132806, #132736, #132539, #132487
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/pytorch#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
  • Loading branch information
ezyang authored and facebook-github-bot committed Aug 15, 2024
1 parent c6db4bc commit 6f5d34a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 6f5d34a

Please sign in to comment.