MCPcopy Create free account
hub / github.com/MiniMax-AI/VTP / forward

Method forward

vtp/models/decoders/pixel_decoder.py:134–162  ·  view source on GitHub ↗
(self, x: Tensor)

Source from the content-addressed store, hash-verified

132 # RoPE does not need init here, it's handled internally
133
134 def forward(self, x: Tensor) -> Tensor:
135 B, _, H, W = x.shape
136
137 # 1. Project in: (B, C, H, W) -> (B, D, H, W)
138 x = self.proj_in(x)
139
140 # 2. Reshape for transformer: (B, D, H, W) -> (B, H*W, D)
141 x = x.flatten(2).transpose(1, 2)
142
143 # 3. Get RoPE:
144 rope_sincos = self.rope_embed(H=H, W=W)
145
146 # 4. Transformer blocks
147 for blk in self.blocks:
148 x = blk(x, rope_sincos)
149
150 # 5. Final Norm
151 x = self.norm(x)
152
153 # 6. Reshape back to image-like: (B, H*W, D) -> (B, D, H, W)
154 x = x.transpose(1, 2).reshape(B, self.embed_dim, H, W)
155
156 # 7. Project out: (B, D, H, W) -> (B, C_out * up_factor^2, H, W)
157 x = self.proj_out(x)
158
159 # 8. Pixel Shuffle: (B, C_out * up_factor^2, H, W) -> (B, C_out, H*up_factor, W*up_factor)
160 x = self.pixel_shuffle(x)
161
162 return x
163
164
165# Factory functions for different model sizes

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected