MCPcopy Create free account
hub / github.com/LTH14/rcg / forward

Method forward

pixel_generator/guided_diffusion/unet.py:43–51  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

41 self.attention = QKVAttention(self.num_heads)
42
43 def forward(self, x):
44 b, c, *_spatial = x.shape
45 x = x.reshape(b, c, -1) # NC(HW)
46 x = th.cat([x.mean(dim=-1, keepdim=True), x], dim=-1) # NC(HW+1)
47 x = x + self.positional_embedding[None, :, :].to(x.dtype) # NC(HW+1)
48 x = self.qkv_proj(x)
49 x = self.attention(x)
50 x = self.c_proj(x)
51 return x[:, :, 0]
52
53
54class TimestepBlock(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected