MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / forward

Method forward

diffsynth/models/sd3_dit.py:77–92  ·  view source on GitHub ↗
(self, x, emb)

Source from the content-addressed store, hash-verified

75 self.norm = torch.nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6)
76
77 def forward(self, x, emb):
78 emb = self.linear(torch.nn.functional.silu(emb))
79 if self.single:
80 scale, shift = emb.unsqueeze(1).chunk(2, dim=2)
81 x = self.norm(x) * (1 + scale) + shift
82 return x
83 elif self.dual:
84 shift_msa, scale_msa, gate_msa, shift_mlp, scale_mlp, gate_mlp, shift_msa2, scale_msa2, gate_msa2 = emb.unsqueeze(1).chunk(9, dim=2)
85 norm_x = self.norm(x)
86 x = norm_x * (1 + scale_msa) + shift_msa
87 norm_x2 = norm_x * (1 + scale_msa2) + shift_msa2
88 return x, gate_msa, shift_mlp, scale_mlp, gate_mlp, norm_x2, gate_msa2
89 else:
90 shift_msa, scale_msa, gate_msa, shift_mlp, scale_mlp, gate_mlp = emb.unsqueeze(1).chunk(6, dim=2)
91 x = self.norm(x) * (1 + scale_msa) + shift_msa
92 return x, gate_msa, shift_mlp, scale_mlp, gate_mlp
93
94
95

Callers

nothing calls this directly

Calls 1

normMethod · 0.80

Tested by

no test coverage detected