8000 Fixes type annotation for numpy arrays · robbiemu/llama.cpp@a6ab097 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6ab097

Browse files
committed
Fixes type annotation for numpy arrays
Corrects type annotations for numpy arrays to allow for a broader range of numpy dtypes and resolves type checking errors. Removes NumPy DTypeLike type hint Updates type hints for NumPy compatibility by removing DTypeLike. Ensures alignment with NumPy's typing system, preventing potential type-related issues.
1 parent c278aff commit a6ab097

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

gguf-py/gguf/quants.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from typing import Any, Callable, Sequence
44
from math import log2, ceil
55

6-
from numpy.typing import DTypeLike
7-
86
from .constants import GGML_QUANT_SIZES, GGMLQuantizationType, QK_K
97
from .lazy import LazyNumpyTensor
108

@@ -26,7 +24,7 @@ def quant_shape_from_byte_shape(shape: Sequence[int], quant_type: GGMLQuantizati
2624

2725

2826
# This is faster than np.vectorize and np.apply_along_axis because it works on more than one row at a time
29-
def _apply_over_grouped_rows(func: Callable[[np.ndarray], np.ndarray], arr: np.ndarray, otype: DTypeLike, oshape: tuple[int, ...]) -> np.ndarray:
27+
def _apply_over_grouped_rows(func: Callable[[np.ndarray], np.ndarray], arr: np.ndarray, otype: np.dtype[Any], oshape: tuple[int, ...]) -> np.ndarray:
3028
rows = arr.reshape((-1, arr.shape[-1]))
3129
osize = 1
3230
for dim in oshape:
@@ -80,7 +78,7 @@ class __Quant(ABC):
8078
block_size: int
8179
type_size: int
8280

83-
grid: np.ndarray[Any, np.dtype[np.float32]] | None = None
81+
grid: np.ndarray | None = None # np.float32
8482
grid_shape: tuple[int, int] = (0, 0)
8583
grid_map: tuple[int | float, ...] = ()
8684
grid_hex: bytes | None = None

0 commit comments

Comments
 (0)
0