From 74a67fad087c594eb42d50e783f628b519c0697b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E9=87=8E?= Date: Tue, 8 Oct 2024 19:28:17 +0800 Subject: [PATCH] cherry pick 6b90ecb from https://gitee.com/tianye0806/pytorch/pulls/15199 fix dfx --- torch_npu/meta/_meta_registrations.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/torch_npu/meta/_meta_registrations.py b/torch_npu/meta/_meta_registrations.py index 4ef81b68eb..c37befc225 100644 --- a/torch_npu/meta/_meta_registrations.py +++ b/torch_npu/meta/_meta_registrations.py @@ -636,8 +636,10 @@ def npu_group_quant_meta(x, scale, group_index, *, offset=None, dst_dtype=None): return torch.empty_like(x, dtype=torch.int8) elif dst_dtype == torch.quint4x2: dim_num = x.dim() + if dim_num == 0: + raise RuntimeError("Input x can't be scalar" + ops_error(ErrCode.NOT_SUPPORT)) if x.size(dim_num - 1) % 8: - raise RuntimeError("If dst_dtype is quint4x2, last dim must be divisible by 8" + + raise RuntimeError("If dst_dtype is quint4x2, x last dim must be divisible by 8" + ops_error(ErrCode.NOT_SUPPORT)) output_shape = [] for dim in range(dim_num - 1): -- Gitee