MCPcopy Create free account
hub / github.com/microsoft/BitNet / permute

Function permute

utils/convert.py:694–699  ·  view source on GitHub ↗
(weights: NDArray, n_head: int, n_head_kv: int)

Source from the content-addressed store, hash-verified

692
693
694def permute(weights: NDArray, n_head: int, n_head_kv: int) -> NDArray:
695 if n_head_kv is not None and n_head != n_head_kv:
696 n_head = n_head_kv
697 return (weights.reshape(n_head, 2, weights.shape[0] // n_head // 2, *weights.shape[1:])
698 .swapaxes(1, 2)
699 .reshape(weights.shape))
700
701
702class Tensor(ABC):

Callers 2

permute_partMethod · 0.70
permuteMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected