MCPcopy Create free account
hub / github.com/ali-vilab/ACE_plus / Modulation

Class Modulation

modules/layers.py:209–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209class Modulation(nn.Module):
210 def __init__(self, dim: int, double: bool):
211 super().__init__()
212 self.is_double = double
213 self.multiplier = 6 if double else 3
214 self.lin = nn.Linear(dim, self.multiplier * dim, bias=True)
215
216 def forward(self, vec: Tensor) -> tuple[ModulationOut, ModulationOut | None]:
217 out = self.lin(nn.functional.silu(vec))[:, None, :].chunk(self.multiplier, dim=-1)
218
219 return (
220 ModulationOut(*out[:3]),
221 ModulationOut(*out[3:]) if self.is_double else None,
222 )
223
224
225class DoubleStreamBlock(nn.Module):

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected