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

Method __init__

diffsynth/models/kolors_text_encoder.py:725–752  ·  view source on GitHub ↗
(self, config: ChatGLMConfig, device=None)

Source from the content-addressed store, hash-verified

723 """
724
725 def __init__(self, config: ChatGLMConfig, device=None):
726 super(MLP, self).__init__()
727
728 self.add_bias = config.add_bias_linear
729
730 # Project to 4h. If using swiglu double the output width, see https://arxiv.org/pdf/2002.05202.pdf
731 self.dense_h_to_4h = nn.Linear(
732 config.hidden_size,
733 config.ffn_hidden_size * 2,
734 bias=self.add_bias,
735 device=device,
736 **_config_to_kwargs(config)
737 )
738
739 def swiglu(x):
740 x = torch.chunk(x, 2, dim=-1)
741 return F.silu(x[0]) * x[1]
742
743 self.activation_func = swiglu
744
745 # Project back to h.
746 self.dense_4h_to_h = nn.Linear(
747 config.ffn_hidden_size,
748 config.hidden_size,
749 bias=self.add_bias,
750 device=device,
751 **_config_to_kwargs(config)
752 )
753
754 def forward(self, hidden_states):
755 # [s, b, 4hp]

Callers 13

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 1

_config_to_kwargsFunction · 0.85

Tested by

no test coverage detected