MCPcopy Create free account
hub / github.com/Robbyant/lingbot-map / forward

Method forward

lingbot_map/layers/patch_embed.py:65–78  ·  view source on GitHub ↗
(self, x: Tensor)

Source from the content-addressed store, hash-verified

63 self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity()
64
65 def forward(self, x: Tensor) -> Tensor:
66 _, _, H, W = x.shape
67 patch_H, patch_W = self.patch_size
68
69 assert H % patch_H == 0, f"Input image height {H} is not a multiple of patch height {patch_H}"
70 assert W % patch_W == 0, f"Input image width {W} is not a multiple of patch width: {patch_W}"
71
72 x = self.proj(x) # B C H W
73 H, W = x.size(2), x.size(3)
74 x = x.flatten(2).transpose(1, 2) # B HW C
75 x = self.norm(x)
76 if not self.flatten_embedding:
77 x = x.reshape(-1, H, W, self.embed_dim) # B H W C
78 return x
79
80 def flops(self) -> float:
81 Ho, Wo = self.patches_resolution

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected