# Codeblock 7b def reorder(self, x, scale=2): # ([1, 64, 26, 26]) B, C, H, W = x.shape h, w = H // scale, W // scale x = x.reshape(B, C, h, scale, w, scale) # ([1, 64, 13, 2, 13, 2]) x = x.transpose(3, 4) # ([1, 64, 13, 13, 2, 2]) x = x.reshape(B, C, h * w, scale * scale) # ([1, 64, 169, 4]) x = x.transpose(2, 3) # ([1, 64, 4, 169]) x = x.reshape(B, C, scale * scale, h, w) # ([1, 64, 4, 13, 13]) x = x.transpose(1, 2) # ([1, 4, 64, 13, 13]) x = x.reshape(B, scale * scale * C, h, w) # ([1, 256, 13, 13]) return x