MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / window_unpartition

Function window_unpartition

tests/dump_phase3_reference.py:92–100  ·  view source on GitHub ↗
(windows, window_size, pad_hw, hw)

Source from the content-addressed store, hash-verified

90
91
92def window_unpartition(windows, window_size, pad_hw, hw):
93 Hp, Wp = pad_hw
94 H, W = hw
95 B = windows.shape[0] // (Hp * Wp // window_size // window_size)
96 x = windows.reshape(B, Hp // window_size, Wp // window_size, window_size, window_size, -1)
97 x = x.permute(0, 1, 3, 2, 4, 5).reshape(B, Hp, Wp, -1)
98 if Hp > H or Wp > W:
99 x = x[:, :H, :W, :]
100 return x
101
102
103def get_abs_pos(abs_pos, has_cls_token, hw, tiling=False):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected