Update davit.py

pull/1630/head
Fredo Guan 3 years ago
parent d8c8c4f4f2
commit 3f14094fcd

@ -415,15 +415,15 @@ class DaViTStage(nn.Module):
self.blocks = nn.ModuleList(*stage_blocks) self.blocks = nn.ModuleList(*stage_blocks)
def forward(self, x : Tensor, size: Tuple[int, int]): def forward(self, x : Tensor, size: Tuple[int, int]):
x, size = self.patch_embed(x, size) x, size = self.patch_embed(x, size)
for block in self.blocks: for block in self.blocks:
for layer in block: for layer in block:
if self.grad_checkpointing and not torch.jit.is_scripting(): if self.grad_checkpointing and not torch.jit.is_scripting():
x, size = checkpoint.checkpoint(layer, x, size) x, size = checkpoint.checkpoint(layer, x, size)
else: else:
x, size = layer(x, size) x, size = layer(x, size)
return x, size return x, size
class DaViT(nn.Module): class DaViT(nn.Module):

Loading…
Cancel
Save