(self, x: Tensor)
| 59 | self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity() |
| 60 | |
| 61 | def forward(self, x: Tensor) -> Tensor: |
| 62 | _, _, H, W = x.shape |
| 63 | |
| 64 | x = self.proj(x) # B C H W |
| 65 | H, W = x.size(2), x.size(3) |
| 66 | x = x.flatten(2).transpose(1, 2) # B HW C |
| 67 | x = self.norm(x) |
| 68 | if not self.flatten_embedding: |
| 69 | x = x.reshape(-1, H, W, self.embed_dim) # B H W C |
| 70 | return x |
| 71 | |
| 72 | def flops(self) -> float: |
| 73 | Ho, Wo = self.patches_resolution |
nothing calls this directly
no outgoing calls
no test coverage detected