MCPcopy Create free account
hub / github.com/Zhiyuan-R/Tiger-Diffusion / forward

Method forward

modules/pvconv.py:39–62  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

37
38
39 def forward(self, x):
40 B, C = x.shape[:2]
41 h = x
42
43
44
45
46 q = self.q(h).reshape(B,C,-1)
47 k = self.k(h).reshape(B,C,-1)
48 v = self.v(h).reshape(B,C,-1)
49
50 qk = torch.matmul(q.permute(0, 2, 1), k) #* (int(C) ** (-0.5))
51
52 w = self.sm(qk)
53
54 h = torch.matmul(v, w.permute(0, 2, 1)).reshape(B,C,*x.shape[2:])
55
56 h = self.out(h)
57
58 x = h + x
59
60 x = self.nonlin(self.norm(x))
61
62 return x
63
64class PVConv(nn.Module):
65 def __init__(self, in_channels, out_channels, kernel_size, resolution, attention=False,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected