]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
convert.py : add missing abstract methods for quantized data (#2491)
authorKeiichi Tabata <redacted>
Sun, 6 Aug 2023 06:34:05 +0000 (15:34 +0900)
committerGitHub <redacted>
Sun, 6 Aug 2023 06:34:05 +0000 (09:34 +0300)
convert.py

index ab6a4e10e49c3ba02ec9c14b9ac75e80ae655b55..f3bf1798089ccd8d4c9f4db85deb313f60d8c175 100644 (file)
@@ -465,6 +465,13 @@ class GGMLQuantizedTensor(Tensor):
     def permute(self, n_head: int, n_kv_head: Optional[int] = None) -> 'GGMLQuantizedTensor':
         return GGMLQuantizedTensor(permute(self.ndarray, n_head, n_kv_head), self.shape, self.data_type)
 
+    def permute_part(self, n_part: int, n_head: int) -> 'UnquantizedTensor':
+        r = self.ndarray.shape[0] // 3
+        return UnquantizedTensor(permute(self.ndarray[r * n_part : r * n_part + r, ...], n_head))
+
+    def part(self, n_part: int) -> 'UnquantizedTensor':
+        r = self.ndarray.shape[0] // 3
+        return UnquantizedTensor(self.ndarray[r * n_part : r * n_part + r, ...])
 
 GGMLCompatibleTensor = Union[UnquantizedTensor, GGMLQuantizedTensor]