MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / window_partition

Function window_partition

PATH/core/models/backbones/vit.py:101–112  ·  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

99
100
101def window_partition(x, window_size):
102 """
103 Args:
104 x: (B, H, W, C)
105 window_size (int): window size
106 Returns:
107 windows: (num_windows*B, window_size, window_size, C)
108 """
109 B, H, W, C = x.shape
110 x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
111 windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
112 return windows
113
114
115def window_reverse(windows, window_size, H, W):

Callers 1

forwardMethod · 0.70

Calls 1

permuteMethod · 0.80

Tested by

no test coverage detected