Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Fix SiLU breakage in RegNets for PT < 1.7 (#725)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #725

SiLU is only available from PT >= 1.7

Now that our tests work fine, we can finally detect and fix issues like these

Reviewed By: kazhang

Differential Revision: D27236649

fbshipit-source-id: ed5bc81a40d1a21def13d81b83b181c55e86f6f5
  • Loading branch information
mannatsingh authored and facebook-github-bot committed Mar 22, 2021
1 parent 4110064 commit c4d9725
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions classy_vision/models/regnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,15 @@ class RegNet(ClassyModel):
def __init__(self, params: RegNetParams):
super().__init__()

if params.activation_type == ActivationType.SILU and get_torch_version() < [
1,
7,
]:
raise RuntimeError("SiLU activation is only supported since PyTorch 1.7")

silu = None if get_torch_version() < [1, 7] else nn.SiLU()
activation = {
ActivationType.RELU: nn.ReLU(params.relu_in_place),
ActivationType.SILU: nn.SiLU(),
ActivationType.SILU: silu,
}[params.activation_type]

if activation is None:
raise RuntimeError("SiLU activation is only supported since PyTorch 1.7")

# Ad hoc stem
self.stem = {
StemType.RES_STEM_CIFAR: ResStemCifar,
Expand Down

0 comments on commit c4d9725

Please sign in to comment.