MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / permute

Function permute

convert-dense.py:426–432  ·  view source on GitHub ↗
(weights: NDArray, n_head: int, n_head_kv: int)

Source from the content-addressed store, hash-verified

424#
425
426def permute(weights: NDArray, n_head: int, n_head_kv: int) -> NDArray:
427 #print( "permute debug " + str(weights.shape[0]) + " x " + str(weights.shape[1]) + " nhead " + str(n_head) + " nheadkv " + str(n_kv_head) )
428 if n_head_kv is not None and n_head != n_head_kv:
429 n_head = n_head_kv
430 return (weights.reshape(n_head, 2, weights.shape[0] // n_head // 2, *weights.shape[1:])
431 .swapaxes(1, 2)
432 .reshape(weights.shape))
433
434
435class Tensor(metaclass=ABCMeta):

Callers 2

permute_partMethod · 0.70
permuteMethod · 0.70

Calls 2

reshapeMethod · 0.80
swapaxesMethod · 0.80

Tested by

no test coverage detected