MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / apply_gate

Function apply_gate

diffsynth/models/step1x_connector.py:170–186  ·  view source on GitHub ↗

AI is creating summary for apply_gate Args: x (torch.Tensor): input tensor. gate (torch.Tensor, optional): gate tensor. Defaults to None. tanh (bool, optional): whether to use tanh function. Defaults to False. Returns: torch.Tensor: the output tensor after a

(x, gate=None, tanh=False)

Source from the content-addressed store, hash-verified

168
169
170def apply_gate(x, gate=None, tanh=False):
171 """AI is creating summary for apply_gate
172
173 Args:
174 x (torch.Tensor): input tensor.
175 gate (torch.Tensor, optional): gate tensor. Defaults to None.
176 tanh (bool, optional): whether to use tanh function. Defaults to False.
177
178 Returns:
179 torch.Tensor: the output tensor after apply gate.
180 """
181 if gate is None:
182 return x
183 if tanh:
184 return x * gate.unsqueeze(1).tanh()
185 else:
186 return x * gate.unsqueeze(1)
187
188
189class RMSNorm(nn.Module):

Callers 2

forwardMethod · 0.70
forwardMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected