Skip to content

Commit

Permalink
Always some torchscript issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rwightman committed Apr 27, 2023
1 parent 528faa0 commit 437d344
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion timm/layers/space_to_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


class SpaceToDepth(nn.Module):
bs: torch.jit.Final[int]

def __init__(self, block_size=4):
super().__init__()
assert block_size == 4
Expand All @@ -12,7 +14,7 @@ def forward(self, x):
N, C, H, W = x.size()
x = x.view(N, C, H // self.bs, self.bs, W // self.bs, self.bs) # (N, C, H//bs, bs, W//bs, bs)
x = x.permute(0, 3, 5, 1, 2, 4).contiguous() # (N, bs, bs, C, H//bs, W//bs)
x = x.view(N, C * (self.bs ** 2), H // self.bs, W // self.bs) # (N, C*bs^2, H//bs, W//bs)
x = x.view(N, C * self.bs * self.bs, H // self.bs, W // self.bs) # (N, C*bs^2, H//bs, W//bs)
return x


Expand Down
2 changes: 2 additions & 0 deletions timm/models/pvt_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def forward(self, x, feat_size: List[int]):


class Attention(nn.Module):
fused_attn: torch.jit.Final[bool]

def __init__(
self,
dim,
Expand Down

0 comments on commit 437d344

Please sign in to comment.