mirror of
https://github.com/vladmandic/automatic
synced 2026-09-08 22:08:42 +02:00
SDNQ simplify check_mats
This commit is contained in:
@@ -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":
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user