Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors on non-contiguous tensors in equalize() Tensor-backend #6772

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

datumbox
Copy link
Contributor

The use of view() in equalize() leads to the following errors when the input is non-contiguous. The problem affects stable:

    hist = torch.bincount(img_chan.view(-1), minlength=256)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

And prototype:

  File "./torchvision/prototype/transforms/functional/_color.py", line 237, in equalize_video
    return equalize_image_tensor(video)
  File "./torchvision/prototype/transforms/functional/_color.py", line 230, in equalize_image_tensor
    return _equalize_image_tensor_vec(image.view(-1, height, width)).view(image.shape)
  File "./torchvision/prototype/features/_feature.py", line 94, in __torch_function__
    output = func(*args, **kwargs or dict())
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

It was first discovered after starting doing end-to-end training with complex Augmentations using the Tensor Backend. The PR updates the use of view() to reshape() to ensure that both operators work as expected.

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks Vasilis!

@datumbox datumbox merged commit c960273 into pytorch:main Oct 14, 2022
@datumbox datumbox deleted the bugfix/equalize_view branch October 14, 2022 12:34
facebook-github-bot pushed a commit that referenced this pull request Oct 17, 2022
Reviewed By: NicolasHug

Differential Revision: D40427466

fbshipit-source-id: 77c8a8aa1d7169ece7d046d591f1c96def0ad29d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants