Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
a4c1aac3
Unverified
Commit
a4c1aac3
authored
Feb 20, 2025
by
Marc Sun
Committed by
GitHub
Feb 20, 2025
Browse files
store activation cls instead of function (#10832)
* store cls instead of an obj * style
parent
b2ca39c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
src/diffusers/models/activations.py
src/diffusers/models/activations.py
+9
-9
No files found.
src/diffusers/models/activations.py
View file @
a4c1aac3
...
...
@@ -24,12 +24,12 @@ from ..utils.import_utils import is_torch_npu_available, is_torch_version
if
is_torch_npu_available
():
import
torch_npu
ACT
IVATION_FUNCTION
S
=
{
"swish"
:
nn
.
SiLU
()
,
"silu"
:
nn
.
SiLU
()
,
"mish"
:
nn
.
Mish
()
,
"gelu"
:
nn
.
GELU
()
,
"relu"
:
nn
.
ReLU
()
,
ACT
2CL
S
=
{
"swish"
:
nn
.
SiLU
,
"silu"
:
nn
.
SiLU
,
"mish"
:
nn
.
Mish
,
"gelu"
:
nn
.
GELU
,
"relu"
:
nn
.
ReLU
,
}
...
...
@@ -44,10 +44,10 @@ def get_activation(act_fn: str) -> nn.Module:
"""
act_fn
=
act_fn
.
lower
()
if
act_fn
in
ACT
IVATION_FUNCTION
S
:
return
ACT
IVATION_FUNCTION
S
[
act_fn
]
if
act_fn
in
ACT
2CL
S
:
return
ACT
2CL
S
[
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment