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

Function permute

convert.py:447–453  ·  view source on GitHub ↗
(weights: NDArray, n_head: int, n_head_kv: int)

Source from the content-addressed store, hash-verified

445#
446
447def permute(weights: NDArray, n_head: int, n_head_kv: int) -> NDArray:
448 #print( "permute debug " + str(weights.shape[0]) + " x " + str(weights.shape[1]) + " nhead " + str(n_head) + " nheadkv " + str(n_kv_head) )
449 if n_head_kv is not None and n_head != n_head_kv:
450 n_head = n_head_kv
451 return (weights.reshape(n_head, 2, weights.shape[0] // n_head // 2, *weights.shape[1:])
452 .swapaxes(1, 2)
453 .reshape(weights.shape))
454
455
456class 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