Skip to content

Conversation

@bhashemian
Copy link
Member

Fixes #3379

Description

This PR updates TileOnGrid to support torch.Tensor through type conversion while the backend is numpy. It also updates the unittests to include torch.Tenor inputs on cpu and cuda device.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • 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.

Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
@bhashemian bhashemian requested review from Nic-Ma and wyli November 23, 2021 01:03
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
@bhashemian bhashemian requested a review from Nic-Ma November 23, 2021 03:38
@Nic-Ma
Copy link
Contributor

Nic-Ma commented Nov 23, 2021

/build

from monai.utils import convert_data_type, convert_to_dst_type
from monai.utils.enums import TransformBackends

__all__ = ["SplitOnGrid", "TileOnGrid"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like SplitOnGrid(2, 2)(torch.arange(12).reshape(1, 3, 4)) works fine but SplitOnGrid(2, 2)(np.arange(12).reshape(1, 3, 4)) doesn't work, could you help fix it here? #3378 was merged too quickly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wyli, sorry I missed this. I will fix it now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x_size, y_size = self.tile_size, self.tile_size
c_len, x_len, y_len = image.shape
c_stride, x_stride, y_stride = image.strides
h_step, w_step = self.step, self.step
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the previous variable x_step is better than h_step, x indicates the axis direction, h indicates height which is the length of x direction

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can fix this too. sorry that I didn't see your comments before merging.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhashemian bhashemian merged commit 5d87b23 into Project-MONAI:dev Nov 23, 2021
@bhashemian bhashemian mentioned this pull request Nov 23, 2021
2 tasks
@bhashemian bhashemian deleted the tile-grid-backend branch November 23, 2021 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update TileOnGrid backend

3 participants