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":