MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / forward

Method forward

benchmark/models/streamvggt/layers/patch_embed.py:59–72  ·  view source on GitHub ↗
(self, x: Tensor)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected