Spaces:
Running
on
L40S
Running
on
L40S
File size: 948 Bytes
d7e58f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn.bricks import Conv2dAdaptivePadding
def test_conv2d_samepadding():
# test Conv2dAdaptivePadding with stride=1
inputs = torch.rand((1, 3, 28, 28))
conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=1)
output = conv(inputs)
assert output.shape == inputs.shape
inputs = torch.rand((1, 3, 13, 13))
conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=1)
output = conv(inputs)
assert output.shape == inputs.shape
# test Conv2dAdaptivePadding with stride=2
inputs = torch.rand((1, 3, 28, 28))
conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=2)
output = conv(inputs)
assert output.shape == torch.Size([1, 3, 14, 14])
inputs = torch.rand((1, 3, 13, 13))
conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=2)
output = conv(inputs)
assert output.shape == torch.Size([1, 3, 7, 7])
|