SDNQ simplify check_mats

This commit is contained in:
Disty0
2025-10-01 01:35:51 +03:00
parent 8c2b76a8da
commit 03382bdd4c
2 changed files with 3 additions and 7 deletions
+1 -2
View File
@@ -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":
+2 -5
View File
@@ -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":