(self, x, mask)
| 204 | return x |
| 205 | |
| 206 | def forward_mae_decoder(self, x, mask): |
| 207 | |
| 208 | x = self.decoder_embed(x) |
| 209 | mask_with_buffer = torch.cat([torch.zeros(x.size(0), self.buffer_size, device=x.device), mask], dim=1) |
| 210 | |
| 211 | # pad mask tokens |
| 212 | mask_tokens = self.mask_token.repeat(mask_with_buffer.shape[0], mask_with_buffer.shape[1], 1).to(x.dtype) |
| 213 | x_after_pad = mask_tokens.clone() |
| 214 | x_after_pad[(1 - mask_with_buffer).nonzero(as_tuple=True)] = x.reshape(x.shape[0] * x.shape[1], x.shape[2]) |
| 215 | |
| 216 | # decoder position embedding |
| 217 | x = x_after_pad + self.decoder_pos_embed_learned |
| 218 | |
| 219 | # apply Transformer blocks |
| 220 | if self.grad_checkpointing and not torch.jit.is_scripting(): |
| 221 | for block in self.decoder_blocks: |
| 222 | x = checkpoint(block, x) |
| 223 | else: |
| 224 | for block in self.decoder_blocks: |
| 225 | x = block(x) |
| 226 | x = self.decoder_norm(x) |
| 227 | |
| 228 | x = x[:, self.buffer_size:] |
| 229 | x = x + self.diffusion_pos_embed_learned |
| 230 | return x |
| 231 | |
| 232 | def forward_loss(self, z, target, mask): |
| 233 | bsz, seq_len, _ = target.shape |
no outgoing calls
no test coverage detected