Skip to content

x.copy_(y) doesn't work with sparse x #8330

@ezyang

Description

@ezyang
>>> i = torch.LongTensor([[0, 2], [1, 0], [1, 2]])
>>> v = torch.FloatTensor([3,      4,      5    ])
>>> x = torch.sparse.FloatTensor(i.t(), v, torch.Size([2,3]))
>>> x2 = torch.sparse.FloatTensor(i.t(), v, torch.Size([2,3]))
>>> x.copy_(x2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: copy does not support torch.sparse.FloatTensor to torch.sparse.FloatTensor copy.

There isn't really any reason this shouldn't work; internally we have all the pieces implemented already.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions