MCPcopy Create free account
hub / github.com/CompVis/diff2flow / forward

Method forward

diff2flow/models/unet/openaimodel.py:54–62  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

52 self.attention = QKVAttention(self.num_heads)
53
54 def forward(self, x):
55 b, c, *_spatial = x.shape
56 x = x.reshape(b, c, -1) # NC(HW)
57 x = th.cat([x.mean(dim=-1, keepdim=True), x], dim=-1) # NC(HW+1)
58 x = x + self.positional_embedding[None, :, :].to(x.dtype) # NC(HW+1)
59 x = self.qkv_proj(x)
60 x = self.attention(x)
61 x = self.c_proj(x)
62 return x[:, :, 0]
63
64
65class TimestepBlock(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected