Skip to content

TileOnGrid support for Tensor input#3384

Merged
bhashemian merged 5 commits intoProject-MONAI:devfrom
bhashemian:tile-grid-backend
Nov 23, 2021
Merged

TileOnGrid support for Tensor input#3384
bhashemian merged 5 commits intoProject-MONAI:devfrom
bhashemian:tile-grid-backend

Conversation

@bhashemian
Copy link
Copy Markdown
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.

@bhashemian bhashemian requested review from Nic-Ma and wyli November 23, 2021 01:03
@bhashemian bhashemian requested a review from Nic-Ma November 23, 2021 03:38
@Nic-Ma
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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