MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / permute

Function permute

tokenizer/convert/convert.py:568–574  ·  view source on GitHub ↗
(weights: NDArray, n_head: int, n_head_kv: int)

Source from the content-addressed store, hash-verified

566
567
568def permute(weights: NDArray, n_head: int, n_head_kv: int) -> NDArray:
569 # print( "permute debug " + str(weights.shape[0]) + " x " + str(weights.shape[1]) + " nhead " + str(n_head) + " nheadkv " + str(n_kv_head) )
570 if n_head_kv is not None and n_head != n_head_kv:
571 n_head = n_head_kv
572 return (weights.reshape(n_head, 2, weights.shape[0] // n_head // 2, *weights.shape[1:])
573 .swapaxes(1, 2)
574 .reshape(weights.shape))
575
576
577class Tensor(metaclass=ABCMeta):

Callers 2

permute_partMethod · 0.85
permuteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected