Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/diffusers/models/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
if is_torch_npu_available():
import torch_npu

ACTIVATION_FUNCTIONS = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a safe change. I could not find anything via github search that might be impacted but I did not search too many cases

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I tried to look also, should be a safe change

"swish": nn.SiLU(),
"silu": nn.SiLU(),
"mish": nn.Mish(),
"gelu": nn.GELU(),
"relu": nn.ReLU(),
ACT2CLS = {
"swish": nn.SiLU,
"silu": nn.SiLU,
"mish": nn.Mish,
"gelu": nn.GELU,
"relu": nn.ReLU,
}


Expand All @@ -44,10 +44,10 @@ def get_activation(act_fn: str) -> nn.Module:
"""

act_fn = act_fn.lower()
if act_fn in ACTIVATION_FUNCTIONS:
return ACTIVATION_FUNCTIONS[act_fn]
if act_fn in ACT2CLS:
return ACT2CLS[act_fn]()
else:
raise ValueError(f"Unsupported activation function: {act_fn}")
raise ValueError(f"activation function {act_fn} not found in ACT2FN mapping {list(ACT2CLS.keys())}")


class FP32SiLU(nn.Module):
Expand Down
Loading