Skip to content

CUDA tensor allows negative values in torch.multinomial #3475

@dnaq

Description

@dnaq
import torch
t = torch.rand(10) #create CPU tensor
t.multinomial(1) #returns a result, as expected
tn = -t
tn.multinomial(1) # throws an exception, as per the documentation
tn = tn.cuda()
tn.multinomial(1) # returns a value, don't know from what distribution
tn.multinomial(1000, True) # returns a tensor of 1000 zeros

Looking at the values returned from tn.multinomial(1) and counting them, it seems like it returns the values of the multinomial distribution taken from t, i.e. that it has ignored the signs of the values. However, it seem like tn.multinomial(n where n > 1) always returns a tensor filled with zeros.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions