File tree Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Expand file tree Collapse file tree 2 files changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -2769,7 +2769,9 @@ def fake_reindex(index): # type: ignore[no-untyped-def]
2769
2769
# TODO: unbacked should not diverge from backed in determining striding
2770
2770
# Need to require contiguous here instead of realize, see:
2771
2771
# https://github.com/pytorch/pytorch/issues/145561
2772
- x = ExternKernel .require_contiguous (x )
2772
+ x = ExternKernel .require_exact_strides (
2773
+ x , FlexibleLayout .contiguous_strides (x .get_size ())
2774
+ )
2773
2775
2774
2776
storage , old_layout = as_storage_and_layout (x , want_contiguous = True )
2775
2777
new_layout = FixedLayout (
Original file line number Diff line number Diff line change @@ -1006,29 +1006,15 @@ def squeeze(x, dim=None):
1006
1006
dims = OrderedSet ((dim ,) if not isinstance (dim , tuple ) else dim )
1007
1007
1008
1008
new_shape = []
1009
- new_stride = []
1010
- is_storage_and_layout = ir .is_storage_and_layout (x )
1011
- original_stride = x .get_stride () if is_storage_and_layout else []
1012
- new_offset = x .get_layout ().offset if is_storage_and_layout else None
1013
1009
for d , s in enumerate (x .get_size ()):
1014
1010
if not (
1015
1011
d in dims
1016
1012
and V .graph .sizevars .evaluate_expr (sympy .Eq (s , 1 ), size_oblivious = True )
1017
1013
):
1018
1014
new_shape .append (s )
1019
- if is_storage_and_layout :
1020
- new_stride .append (original_stride [d ])
1021
1015
1022
1016
# squeeze does nothing if the size isn't 1
1023
- return (
1024
- (
1025
- as_strided (x , new_shape , new_stride , new_offset )
1026
- if is_storage_and_layout
1027
- else view (x , new_shape )
1028
- )
1029
- if new_shape != x .get_size ()
1030
- else x
1031
- )
1017
+ return view (x , new_shape ) if new_shape != x .get_size () else x
1032
1018
1033
1019
1034
1020
@register_lowering (aten .squeeze_copy , type_promotion_kind = None )
You can’t perform that action at this time.
0 commit comments