MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / forward

Method forward

dmidas/backbones/next_vit.py:315–335  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

313 self.is_bn_merged = True
314
315 def forward(self, x):
316 x = self.patch_embed(x)
317 B, C, H, W = x.shape
318 if not torch.onnx.is_in_onnx_export() and not self.is_bn_merged:
319 out = self.norm1(x)
320 else:
321 out = x
322 out = rearrange(out, "b c h w -> b (h w) c") # b n c
323 out = self.mhsa_path_dropout(self.e_mhsa(out))
324 x = x + rearrange(out, "b (h w) c -> b c h w", h=H)
325
326 out = self.projection(x)
327 out = out + self.mhca_path_dropout(self.mhca(out))
328 x = torch.cat([x, out], dim=1)
329
330 if not torch.onnx.is_in_onnx_export() and not self.is_bn_merged:
331 out = self.norm2(x)
332 else:
333 out = x
334 x = x + self.mlp_path_dropout(self.mlp(out))
335 return x
336
337
338class NextViT(nn.Module):

Callers

nothing calls this directly

Calls 1

catMethod · 0.80

Tested by

no test coverage detected