(self, x, interpolation=False, use_31_block=False)
| 277 | proj_dropout, norm_eps) |
| 278 | |
| 279 | def forward(self, x, interpolation=False, use_31_block=False): |
| 280 | b = x.size(0) |
| 281 | |
| 282 | # embeddings |
| 283 | x = self.patch_embedding(x).flatten(2).permute(0, 2, 1) |
| 284 | if self.pool_type in ('token', 'token_fc'): |
| 285 | x = torch.cat([self.cls_embedding.expand(b, -1, -1), x], dim=1) |
| 286 | if interpolation: |
| 287 | e = pos_interpolate(self.pos_embedding, x.size(1)) |
| 288 | else: |
| 289 | e = self.pos_embedding |
| 290 | x = self.dropout(x + e) |
| 291 | if self.pre_norm is not None: |
| 292 | x = self.pre_norm(x) |
| 293 | |
| 294 | # transformer |
| 295 | if use_31_block: |
| 296 | x = self.transformer[:-1](x) |
| 297 | return x |
| 298 | else: |
| 299 | x = self.transformer(x) |
| 300 | return x |
| 301 | |
| 302 | |
| 303 | class XLMRobertaWithHead(XLMRoberta): |
nothing calls this directly
no test coverage detected