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

[hotfix] IsContiguous failed when tensor's size on first dimension is 1. #2127

Merged
merged 2 commits into from
Aug 30, 2020

Conversation

yzh119
Copy link
Member

@yzh119 yzh119 commented Aug 29, 2020

Description

See #2118 .

When tensor's size on first dimension is 1, the stride on first dimension does not strictly equals the production of sizes on following dimensions:

>>> torch.randn((1, 5, 3))[:, :3, :].contiguous().stride()  # (15, 3, 1), however, we expect (9, 3, 1)

Checklist

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [$CATEGORY] (such as [NN], [Model], [Doc], [Feature]])
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented
  • To the my best knowledge, examples are either not affected by this change,
    or have been fixed to be compatible with this change
  • Related issue is referred in this PR

@yzh119 yzh119 requested a review from BarclayII August 29, 2020 18:12
@BarclayII
Copy link
Collaborator

Not necessarily the first dimension. The tensor is considered contiguous if the first few dimensions are all 1.

https://github.com/pytorch/pytorch/blob/60ad7e9c043b566db44bf648b71496a99fbc22d6/c10/core/TensorImpl.cpp#L84-L100

@yzh119
Copy link
Member Author

yzh119 commented Aug 29, 2020

I see

@BarclayII BarclayII merged commit 7816c5a into dmlc:master Aug 30, 2020
kingmbc pushed a commit to kingmbc/dgl that referenced this pull request Aug 30, 2020
… 1. (dmlc#2127)

* udp

* fix

Co-authored-by: Quan Gan <coin2028@hotmail.com>
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.

None yet

2 participants