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

Multiplication of scalar COO sparse tensors leads to internal assert failure #65396

Closed
pearu opened this issue Sep 21, 2021 · 0 comments
Closed
Assignees
Labels
module: assert failure The issue involves an assert failure module: sparse Related to torch.sparse triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@pearu
Copy link
Collaborator

pearu commented Sep 21, 2021

🐛 Bug

As in the title.

To Reproduce

>>> import torch
>>> t = torch.tensor(1).to_sparse()
>>> t
tensor(indices=tensor([], size=(0, 1)),
       values=tensor([1]),
       size=(), nnz=1, layout=torch.sparse_coo)
>>> t * t
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: r.is_sparse()INTERNAL ASSERT FAILED at "../aten/src/ATen/native/sparse/SparseTensorMath.cpp":54, please report a bug to PyTorch. 

Expected behavior

No internal assert failure.

In addition, the multiplication should succeed:

>>> t * t
tensor(indices=tensor([], size=(0, 1)),
       values=tensor([1]),
       size=(), nnz=1, layout=torch.sparse_coo)

Environment

  • PyTorch Version (e.g., 1.0): 1.10.0a0

Additional context

Notice that the addition of scalar COO tensors works correctly

>>> t + t
tensor(indices=tensor([], size=(0, 1)),
       values=tensor([2]),
       size=(), nnz=1, layout=torch.sparse_coo)

cc @nikitaved @pearu @cpuhrsch @IvanYashchuk

@pearu pearu added module: sparse Related to torch.sparse module: assert failure The issue involves an assert failure labels Sep 21, 2021
@malfet malfet added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Sep 21, 2021
@pearu pearu self-assigned this Jan 5, 2022
@pearu pearu linked a pull request Jan 5, 2022 that will close this issue
pearu added a commit that referenced this issue Jan 6, 2022
Fixes #65396 and a clang-tidy error.





cc nikitaved pearu cpuhrsch

Differential Revision: [D33439136](https://our.internmc.facebook.com/intern/diff/D33439136)

[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: assert failure The issue involves an assert failure module: sparse Related to torch.sparse triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants