aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeiichi Tabata <keiichi.tabata@outlook.com>2023-08-06 15:34:05 +0900
committerGitHub <noreply@github.com>2023-08-06 09:34:05 +0300
commit2e8265ae1764d6288aab0e2df641909072e2d58e (patch)
tree339cb1a562357c7682a49e3b3841807bd76b5fc6
parentf514d1b306e1114c2884fcb25dd9bd48ae64ba32 (diff)
convert.py : add missing abstract methods for quantized data (#2491)
-rw-r--r--convert.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/convert.py b/convert.py
index ab6a4e1..f3bf179 100644
--- a/convert.py
+++ b/convert.py
@@ -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]