Skip to content

Implement GridSplit using torch.as_strided#4768

Merged
wyli merged 2 commits intoProject-MONAI:devfrom
bhashemian:torch-as-strided
Jul 27, 2022
Merged

Implement GridSplit using torch.as_strided#4768
wyli merged 2 commits intoProject-MONAI:devfrom
bhashemian:torch-as-strided

Conversation

@bhashemian
Copy link
Copy Markdown
Member

@bhashemian bhashemian commented Jul 26, 2022

Fixes #4286

Description

This PR implements GridSplit using torch.as_strided instead of torch.unfold, which provides significant speedup.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Jul 27, 2022

/build

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jul 27, 2022

Hi @drbeh ,

Thanks for the investigation and test.
I see some related discussion in PyTorch, torch.as_strided returns the view of the original Tensor, should we test again with contiguous()? PyTorch collate_fn needs the data to be contiguous.
pytorch/pytorch#60466 (comment)

Thanks.

@wyli
Copy link
Copy Markdown
Contributor

wyli commented Jul 27, 2022

/build

@wyli wyli enabled auto-merge (squash) July 27, 2022 15:03
@wyli wyli merged commit 4831909 into Project-MONAI:dev Jul 27, 2022
@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jul 27, 2022

Looks good to me now, thanks for the update.

@bhashemian bhashemian deleted the torch-as-strided branch July 27, 2022 18:29
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.

GridSplit torch vs numpy performance

4 participants