MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / window_partition

Function window_partition

semantic_sam/backbone/swin.py:49–60  ·  view source on GitHub ↗

Args: x: (B, H, W, C) window_size (int): window size Returns: windows: (num_windows*B, window_size, window_size, C)

(x, window_size)

Source from the content-addressed store, hash-verified

47
48
49def window_partition(x, window_size):
50 """
51 Args:
52 x: (B, H, W, C)
53 window_size (int): window size
54 Returns:
55 windows: (num_windows*B, window_size, window_size, C)
56 """
57 B, H, W, C = x.shape
58 x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
59 windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
60 return windows
61
62
63def window_reverse(windows, window_size, H, W):

Callers 2

forwardMethod · 0.70
forwardMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected