From 03382bdd4cc4644c0ac657fafda9b2bbf9ef0038 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Wed, 1 Oct 2025 01:35:51 +0300 Subject: [PATCH] SDNQ simplify check_mats --- modules/sdnq/__init__.py | 3 +-- modules/sdnq/layers/linear/forward.py | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/sdnq/__init__.py b/modules/sdnq/__init__.py index 1a3686ccf..450b43d43 100644 --- a/modules/sdnq/__init__.py +++ b/modules/sdnq/__init__.py @@ -172,8 +172,7 @@ def sdnq_quantize_layer(layer, weights_dtype="int8", torch_dtype=None, group_siz if use_quantized_matmul and not re_quantize_for_matmul: scale.transpose_(0,1) layer.weight.transpose_(0,1) - weight_stride = layer.weight.stride() - if not (weight_stride[0] == 1 and weight_stride[1] > 1): + if layer.weight.is_contiguous(): if devices.backend != "ipex": layer.weight.data = layer.weight.t_().contiguous().t_() elif devices.backend == "ipex": diff --git a/modules/sdnq/layers/linear/forward.py b/modules/sdnq/layers/linear/forward.py index d404966c8..18009c27b 100644 --- a/modules/sdnq/layers/linear/forward.py +++ b/modules/sdnq/layers/linear/forward.py @@ -6,11 +6,8 @@ import torch def check_mats(input: torch.Tensor, weight: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]: - input_stride = input.stride() - if not (input_stride[0] > input_stride[1] and input_stride[1] == 1): - input = input.contiguous() - weight_stride = weight.stride() - if not (weight_stride[0] == 1 and weight_stride[1] > 1): + input = input.contiguous() + if weight.is_contiguous(): if weight.device.type != "xpu": weight = weight.t().contiguous().t() elif weight.device.type == "xpu":