parent
ca35c93825
commit
33d75adadf
1 changed files with 12 additions and 0 deletions
|
|
@ -100,6 +100,12 @@ def ggml_q_format_convet_cpu2xpu(tensor: torch.Tensor, num_elem: int, qtype: int
|
||||||
|
|
||||||
if qtype == ggml_tensor_qtype["sym_int4"]:
|
if qtype == ggml_tensor_qtype["sym_int4"]:
|
||||||
dst_tensor = torch.empty_like(tensor)
|
dst_tensor = torch.empty_like(tensor)
|
||||||
|
elif qtype == ggml_tensor_qtype["sym_int5"]:
|
||||||
|
QK = ggml.ggml_qk_size(qtype)
|
||||||
|
block_size_in_bytes = ggml.ggml_type_size(ggml_tensor_qtype["asym_int5"])
|
||||||
|
dst_size = (num_elem // QK) * block_size_in_bytes
|
||||||
|
dst_tensor = torch.empty(dst_size, dtype=torch.uint8,
|
||||||
|
device=torch.device('cpu'))
|
||||||
else:
|
else:
|
||||||
return tensor
|
return tensor
|
||||||
dst = ctypes.c_void_p(dst_tensor.data.data_ptr())
|
dst = ctypes.c_void_p(dst_tensor.data.data_ptr())
|
||||||
|
|
@ -119,6 +125,12 @@ def ggml_q_format_convet_xpu2cpu(tensor: torch.Tensor, num_elem: int, qtype: int
|
||||||
|
|
||||||
if qtype == ggml_tensor_qtype["sym_int4"]:
|
if qtype == ggml_tensor_qtype["sym_int4"]:
|
||||||
dst_tensor = torch.empty_like(tensor)
|
dst_tensor = torch.empty_like(tensor)
|
||||||
|
elif qtype == ggml_tensor_qtype["sym_int5"]:
|
||||||
|
QK = ggml.ggml_qk_size(ggml_tensor_qtype["asym_int5"])
|
||||||
|
block_size_in_bytes = ggml.ggml_type_size(qtype)
|
||||||
|
dst_size = (num_elem // QK) * block_size_in_bytes
|
||||||
|
dst_tensor = torch.empty(dst_size, dtype=torch.uint8,
|
||||||
|
device=torch.device('cpu'))
|
||||||
else:
|
else:
|
||||||
return tensor
|
return tensor
|
||||||
dst = ctypes.c_void_p(dst_tensor.data.data_ptr())
|
dst = ctypes.c_void_p(dst_tensor.data.data_ptr())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue