MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / SwiGLU

Class SwiGLU

wan/models/wan_image_encoder.py:96–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94
95
96class SwiGLU(nn.Module):
97
98 def __init__(self, dim, mid_dim):
99 super().__init__()
100 self.dim = dim
101 self.mid_dim = mid_dim
102
103 # layers
104 self.fc1 = nn.Linear(dim, mid_dim)
105 self.fc2 = nn.Linear(dim, mid_dim)
106 self.fc3 = nn.Linear(mid_dim, dim)
107
108 def forward(self, x):
109 x = F.silu(self.fc1(x)) * self.fc2(x)
110 x = self.fc3(x)
111 return x
112
113
114class AttentionBlock(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected