MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / forward

Method forward

wan/models/wan_vae.py:244–266  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

242 nn.init.zeros_(self.proj.weight)
243
244 def forward(self, x):
245 identity = x
246 b, c, t, h, w = x.size()
247 x = rearrange(x, 'b c t h w -> (b t) c h w')
248 x = self.norm(x)
249 # compute query, key, value
250 q, k, v = self.to_qkv(x).reshape(b * t, 1, c * 3,
251 -1).permute(0, 1, 3,
252 2).contiguous().chunk(
253 3, dim=-1)
254
255 # apply attention
256 x = F.scaled_dot_product_attention(
257 q,
258 k,
259 v,
260 )
261 x = x.squeeze(1).permute(0, 2, 1).reshape(b * t, c, h, w)
262
263 # output
264 x = self.proj(x)
265 x = rearrange(x, '(b t) c h w-> b c t h w', t=t)
266 return x + identity
267
268
269class Encoder3d(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected