2626 import onnx_ir as ir
2727
2828
29- def _swish (op : OpBuilder , x ):
30- """Swish activation: x * sigmoid(x)."""
31- return op .Mul (x , op .Sigmoid (x ))
32-
33-
3429# ---------------------------------------------------------------------------
3530# Private helper modules
3631# ---------------------------------------------------------------------------
@@ -40,7 +35,7 @@ class _SwishModule(nn.Module):
4035 """Swish activation as an nn.Module (no parameters)."""
4136
4237 def forward (self , op : OpBuilder , x : ir .Value ):
43- return op .Mul ( x , op . Sigmoid ( x ) )
38+ return op .Swish ( x )
4439
4540
4641class _ReLUModule (nn .Module ):
@@ -133,7 +128,7 @@ def __init__(self, input_dim: int, output_dim: int):
133128 def forward (self , op : OpBuilder , x : ir .Value ):
134129 x = self .linear (op , x ) # [B, T, output_dim * 2]
135130 first , second = op .Split (x , axis = - 1 , num_outputs = 2 , _outputs = 2 )
136- return op .Mul (first , _swish ( op , second ))
131+ return op .Mul (first , op . Swish ( second ))
137132
138133
139134class _GLUPointWiseConv (nn .Module ):
@@ -155,7 +150,7 @@ def forward(self, op: OpBuilder, x: ir.Value):
155150 first , second = op .Split (glu_out , axis = 1 , num_outputs = 2 , _outputs = 2 )
156151 first = op .Add (first , self .b1 )
157152 second = op .Add (second , self .b2 )
158- return op .Mul (first , _swish ( op , second ))
153+ return op .Mul (first , op . Swish ( second ))
159154
160155
161156class _DepthwiseSepConv (nn .Module ):
@@ -355,7 +350,7 @@ def forward(self, op: OpBuilder, x: ir.Value):
355350 x = self .dw_sep_conv_1d (op , x )
356351
357352 # Swish + final pointwise conv
358- x = _swish ( op , x )
353+ x = op . Swish ( x )
359354 x = self .ext_pw_conv_1d (op , x )
360355
361356 return op .Transpose (x , perm = [0 , 2 , 1 ]) # [B, T, C]
0 commit comments