torch-mlir/python
Gaurav Shukla e57d3f9774 [LINALG] Fix `aten.bernoulli` op lowering
- This commit adds E2E support for `aten.rand_like` and
  `aten.bernoulli_.Tensor` ops.
- The `aten.bernoulli(x)` was implemented as:
  `aten.bernoulli(x) = rand_like(x) < 0.5`, assuming 0.5 as default
  probability, whereas according to the pytorch documentation:
  https://pytorch.org/docs/stable/generated/torch.bernoulli.html#torch.bernoulli
  the input x in `aten.bernoulli(x)` is itself a tensor containing
  probabilities to be used for drawing the binary random number.
- So this commit fixes the `aten.bernoulli(x)` implementation as:
  `aten.bernoulli(x) = rand_like(x) < x`.
- It also fixes the case where the input to `aten.bernoulli_.float` is
  an integer tensor. In this case the input must be casted to float type
  before passing it as operand to `aten.rand_like` op.
  `aten.bernoulli_.float(x, p) = rand_like(float(x)) < p`.

Signed-Off-by: Gaurav Shukla <gaurav@nod-labs.com>
2022-03-05 09:38:22 +05:30
..
test Make error reporting a bit better. 2021-10-28 13:20:16 -07:00
torch_mlir/dialects [LINALG] Fix `aten.bernoulli` op lowering 2022-03-05 09:38:22 +05:30
torch_mlir_e2e_test Add bufferization pass for TMTensor ops 2022-03-03 11:39:14 -05:00
CMakeLists.txt Enable python extensions when building out of tree (#363) 2021-10-27 17:04:12 -07:00
TorchMLIRModule.cpp Dual license the torch-mlir project. 2021-10-01 10:46:08 -07:00