Skip to content

Commit

Permalink
5574 Fix MBConvBlock issue in 3d (#6672)
Browse files Browse the repository at this point in the history
Fixes #5574 .

### Description

This PR is used to fix the `MBConvBlock` issue when `spatial_dims` is
not 2.
The PR follows the work in:
#5695
As it was not updated after review.
Thanks @swilson314 for posting the issue!

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Yiheng Wang <vennw@nvidia.com>
  • Loading branch information
yiheng-wang-nv authored Jun 29, 2023
1 parent 9e14615 commit cbf5d3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions monai/networks/nets/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def __init__(
self._se_adaptpool = adaptivepool_type(1)
num_squeezed_channels = max(1, int(in_channels * self.se_ratio))
self._se_reduce = conv_type(in_channels=oup, out_channels=num_squeezed_channels, kernel_size=1)
self._se_reduce_padding = _make_same_padder(self._se_reduce, [1, 1])
self._se_reduce_padding = _make_same_padder(self._se_reduce, [1] * spatial_dims)
self._se_expand = conv_type(in_channels=num_squeezed_channels, out_channels=oup, kernel_size=1)
self._se_expand_padding = _make_same_padder(self._se_expand, [1, 1])
self._se_expand_padding = _make_same_padder(self._se_expand, [1] * spatial_dims)

# Pointwise convolution phase
final_oup = out_channels
Expand Down
7 changes: 7 additions & 0 deletions tests/test_vitautoenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@


class TestPatchEmbeddingBlock(unittest.TestCase):
def setUp(self):
self.threads = torch.get_num_threads()
torch.set_num_threads(4)

def tearDown(self):
torch.set_num_threads(self.threads)

@parameterized.expand(TEST_CASE_Vitautoenc)
@skip_if_windows
def test_shape(self, input_param, input_shape, expected_shape):
Expand Down
1 change: 1 addition & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def skip_if_downloading_fails():
"md5 check",
"limit", # HTTP Error 503: Egress is over the account limit
"authenticate",
"timed out", # urlopen error [Errno 110] Connection timed out
)
):
raise unittest.SkipTest(f"error while downloading: {rt_e}") from rt_e # incomplete download
Expand Down

0 comments on commit cbf5d3f

Please sign in to comment.