x: B, H*W, C
(self, x)
| 312 | self.norm = norm_layer(4 * dim) |
| 313 | |
| 314 | def forward(self, x): |
| 315 | """ |
| 316 | x: B, H*W, C |
| 317 | """ |
| 318 | H, W = self.input_resolution |
| 319 | B, L, C = x.shape |
| 320 | assert L == H * W, "input feature has wrong size" |
| 321 | assert H % 2 == 0 and W % 2 == 0, f"x size ({H}*{W}) are not even." |
| 322 | |
| 323 | x = x.view(B, H, W, C) |
| 324 | |
| 325 | x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C |
| 326 | x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C |
| 327 | x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C |
| 328 | x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C |
| 329 | x = torch.cat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C |
| 330 | x = x.view(B, -1, 4 * C) # B H/2*W/2 4*C |
| 331 | |
| 332 | x = self.norm(x) |
| 333 | x = self.reduction(x) |
| 334 | |
| 335 | return x |
| 336 | |
| 337 | def extra_repr(self) -> str: |
| 338 | return f"input_resolution={self.input_resolution}, dim={self.dim}" |
nothing calls this directly
no outgoing calls
no test coverage detected