From 5cad1e7ded86b3b30f2405818aa56a7dd804e8ce Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 29 Apr 2024 13:31:58 -0700 Subject: [PATCH] Update [ghstack-poisoned] --- torch/_refs/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/torch/_refs/__init__.py b/torch/_refs/__init__.py index b209ebb1a94a..f9d6aafd686d 100644 --- a/torch/_refs/__init__.py +++ b/torch/_refs/__init__.py @@ -3715,7 +3715,10 @@ def _reshape_view_helper(a: TensorLikeType, *shape, allow_copy: bool) -> TensorL # Squeezes tail while idx < a_.ndim: - assert a_.shape[idx] == 1 + torch._check( + a_.shape[idx] == 1, + lambda: f"a.size({idx}) expected to be 1 but got {a_.shape[idx]}", + ) a_ = squeeze(a_, idx) return a_