MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / forward

Method forward

sat/sgm/modules/diffusionmodules/openaimodel.py:57–65  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

toMethod · 0.80
attentionMethod · 0.45

Tested by

no test coverage detected