-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Register a new activatation layer SiLU to ACTIVATION_LAYERS (…
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 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) |