mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00
[Feature] support pool (#3827)
* support pool * update pooling * add pooler_config and check * update * support AutoWeightsLoader load weight * fix * update * delete print * update pre-commit * fix * fix xpu * fix ModelRegistry->model_registry * fix Copilot review * fix pooler.py * delete StepPooler * fix abstract * fix default_loader_v1 * fix Pre Commit * support torch qwen3 dense * add test and fix torch-qwen * fix * fix * adapter ci: * fix review * fix pooling_params.py * fix * fix tasks.py 2025 * fix print and logger * Modefy ModelRegistry and delete AutoWeightsLoader * fix logger * fix test_embedding * fix ci bug * ernie4_5 model_registry * fix test * support Qwen3-Embedding-0.6B tp=1 load * fix extra code * fix * delete fix vocab_size * delete prepare_params_dict * fix:
This commit is contained in:
@@ -146,3 +146,26 @@ class SiluAndMul(nn.Layer):
|
||||
if self.bias is not None:
|
||||
out = out + self.bias
|
||||
return out
|
||||
|
||||
|
||||
def get_act_fn(act_fn_name: str) -> nn.Layer:
|
||||
"""Get an activation function by name."""
|
||||
act_fn_name = act_fn_name.lower()
|
||||
|
||||
if act_fn_name.startswith("paddle.nn.Layer"):
|
||||
activation_name = act_fn_name.split(".")[-1]
|
||||
if activation_name == "identity":
|
||||
return nn.Identity()
|
||||
act_fn_name = activation_name
|
||||
|
||||
activation_map = {
|
||||
"gelu": nn.GELU(),
|
||||
"relu": nn.ReLU(),
|
||||
"silu": nn.Silu(),
|
||||
"tanh": nn.Tanh(),
|
||||
"sigmoid": nn.Sigmoid(),
|
||||
}
|
||||
if act_fn_name in activation_map:
|
||||
return activation_map[act_fn_name]
|
||||
else:
|
||||
raise ValueError(f"Activation function {act_fn_name!r} is not supported.")
|
||||
|
Reference in New Issue
Block a user