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
OpenDAS
MMCV
Commits
dfef1529
Commit
dfef1529
authored
Sep 13, 2022
by
takuoko
Committed by
Zaida Zhou
Oct 22, 2022
Browse files
[Feature] Register a new activatation layer SiLU to ACTIVATION_LAYERS
parent
ecc9800a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
mmcv/cnn/bricks/activation.py
mmcv/cnn/bricks/activation.py
+3
-0
tests/test_cnn/test_silu.py
tests/test_cnn/test_silu.py
+21
-0
No files found.
mmcv/cnn/bricks/activation.py
View file @
dfef1529
...
...
@@ -14,6 +14,9 @@ for module in [
]:
MODELS
.
register_module
(
module
=
module
)
if
digit_version
(
torch
.
__version__
)
>=
digit_version
(
'1.7.0'
):
MODELS
.
register_module
(
module
=
nn
.
SiLU
)
@
MODELS
.
register_module
(
name
=
'Clip'
)
@
MODELS
.
register_module
()
...
...
tests/test_cnn/test_silu.py
0 → 100644
View file @
dfef1529
# Copyright (c) OpenMMLab. All rights reserved.
import
pytest
import
torch
import
torch.nn.functional
as
F
from
mmcv.cnn.bricks
import
build_activation_layer
from
mmcv.utils
import
digit_version
@
pytest
.
mark
.
skipif
(
digit_version
(
torch
.
__version__
)
<
digit_version
(
'1.7.0'
),
reason
=
'torch.nn.SiLU is not available before 1.7.0'
)
def
test_silu
():
act
=
build_activation_layer
(
dict
(
type
=
'SiLU'
))
input
=
torch
.
randn
(
1
,
3
,
64
,
64
)
expected_output
=
F
.
silu
(
input
)
output
=
act
(
input
)
# test output shape
assert
output
.
shape
==
expected_output
.
shape
# test output value
assert
torch
.
equal
(
output
,
expected_output
)
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