Skip to content

weird new() method of torch.cuda.sparse tensor #2249

@synxlin

Description

@synxlin

Let say,

a = torch.sparse.FloatTensor(torch.LongTensor([[0]]), torch.FloatTensor([0]), torch.Size([1]))
a = a.cuda(1)

when I try,

i = torch.LongTensor([[0, 1], [2, 0]])
v = torch.FloatTensor([3, 4])
i = i.cuda(1)
v = v.cuda(1)
b = a.new(i, v, torch.Size([2,3]))

it throws error: arguments are located on different GPUs
But when I try,

i = i.cuda(0)
v = v.cuda(0)
b = a.new(i, v, torch.Size([2,3]))

then it will make b a sparse tensor on GPU 0.
Besides,

a = a.new()
print(a.get_device()) # sometimes print 0 and sometimes print -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions