mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2025-09-08 05:29:29 +00:00
Merge pull request #670 from akemimadoka/fix-win
Fix RuntimeError on Windows caused by integer overflow in np.prod
This commit is contained in:
commit
0422152cf3
1 changed files with 2 additions and 1 deletions
|
@ -27,6 +27,7 @@ import torch
|
||||||
import KTransformersOps
|
import KTransformersOps
|
||||||
from .custom_loader import SafeTensorLoader
|
from .custom_loader import SafeTensorLoader
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import math
|
||||||
|
|
||||||
class GGMLQuantizationType(IntEnum):
|
class GGMLQuantizationType(IntEnum):
|
||||||
F32 = 0
|
F32 = 0
|
||||||
|
@ -230,7 +231,7 @@ class GGUFLoader:
|
||||||
shape = [read_value(f, DATA_TYPES["uint64"]) for _ in range(shape_len)]
|
shape = [read_value(f, DATA_TYPES["uint64"]) for _ in range(shape_len)]
|
||||||
ggml_type = read_value(f, DATA_TYPES["uint32"])
|
ggml_type = read_value(f, DATA_TYPES["uint32"])
|
||||||
bad_offset = read_value(f, DATA_TYPES["uint64"])
|
bad_offset = read_value(f, DATA_TYPES["uint64"])
|
||||||
n_elems = int(np.prod(shape))
|
n_elems = int(math.prod(shape))
|
||||||
block_size, type_size = GGML_QUANT_SIZES[ggml_type]
|
block_size, type_size = GGML_QUANT_SIZES[ggml_type]
|
||||||
n_bytes = n_elems * type_size // block_size
|
n_bytes = n_elems * type_size // block_size
|
||||||
np_dims = tuple(reversed(shape))
|
np_dims = tuple(reversed(shape))
|
||||||
|
|
Loading…
Add table
Reference in a new issue