Skip to content

torch.bernoulli's out kwarg is broken #10236

@emerali

Description

@emerali

Issue description

torch.bernoulli() can no longer overwrite a desired tensor

Code example

>>> import torch
>>> a = torch.ones(10) * 0.5
>>> b = torch.zeros_like(a)
>>> a
tensor([0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000, 0.5000,
        0.5000])
>>> b
tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
>>> torch.bernoulli(a, out=b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bernoulli() received an invalid combination of arguments - got (Tensor, out=Tensor), but expected one of:
 * (Tensor input)
 * (Tensor input, Tensor p, torch.Generator generator)
 * (Tensor input, float p, torch.Generator generator)

>>> b
tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])

I get a similar error if i try to do a.bernoulli(out=b)

System Info

  • PyTorch or Caffe2: PyTorch
  • How you installed PyTorch (conda, pip, source): pip
  • Build command you used (if compiling from source): n/a
  • OS: Ubuntu 18.04
  • PyTorch version: 0.4.1
  • Python version: 3.6.5
  • CUDA/cuDNN version: 9.1
  • GPU models and configuration: GeForce GTX 860M (though I didn't use it for this example)
  • GCC version (if compiling from source): n/a
  • CMake version: 3.10.2
  • Versions of any other relevant libraries:

Metadata

Metadata

Assignees

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