MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / forward

Method forward

k_diffusion/layers.py:330–337  ·  view source on GitHub ↗
(self, input, cond)

Source from the content-addressed store, hash-verified

328 nn.init.zeros_(self.out_proj.bias)
329
330 def forward(self, input, cond):
331 n, c, h, w = input.shape
332 qkv = self.qkv_proj(self.norm_in(input, cond))
333 qkv = qkv.view([n, self.n_head * 3, c // self.n_head, h * w]).transpose(2, 3)
334 q, k, v = qkv.chunk(3, dim=1)
335 y = F.scaled_dot_product_attention(q, k, v, dropout_p=self.dropout.p)
336 y = y.transpose(2, 3).contiguous().view([n, c, h, w])
337 return input + self.out_proj(y)
338
339
340class CrossAttention2d(ConditionedModule):

Callers

nothing calls this directly

Calls 1

transposeMethod · 0.80

Tested by

no test coverage detected