Commit dc0c41c
authored
* Fix torch.randint producing values equal to the upper bound (#2568)
torch.randint is documented as returning integers in [low, high), but the
lowering used mb.random_uniform whose upper bound is inclusive — and
cast-to-int truncates toward zero, so a sample exactly at high stays at
high after casting. The reporter saw torch.randint(0, 100, ...) produce
values up to 100.
Clamp the cast result to high - 1 with mb.minimum so the converted graph
matches torch's exclusive upper bound. Adds a regression test that asserts
the lowered MIL graph contains the clamp op.
* Check randint upper bound via prediction instead of MIL op-type walk
1 parent 82c89a8 commit dc0c41c
2 files changed
Lines changed: 43 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5654 | 5654 | | |
5655 | 5655 | | |
5656 | 5656 | | |
5657 | | - | |
| 5657 | + | |
| 5658 | + | |
| 5659 | + | |
| 5660 | + | |
| 5661 | + | |
| 5662 | + | |
| 5663 | + | |
| 5664 | + | |
5658 | 5665 | | |
5659 | 5666 | | |
5660 | 5667 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4748 | 4748 | | |
4749 | 4749 | | |
4750 | 4750 | | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
| 4754 | + | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
| 4767 | + | |
| 4768 | + | |
| 4769 | + | |
| 4770 | + | |
| 4771 | + | |
| 4772 | + | |
| 4773 | + | |
| 4774 | + | |
| 4775 | + | |
| 4776 | + | |
| 4777 | + | |
| 4778 | + | |
| 4779 | + | |
| 4780 | + | |
| 4781 | + | |
| 4782 | + | |
| 4783 | + | |
| 4784 | + | |
| 4785 | + | |
4751 | 4786 | | |
4752 | 4787 | | |
4753 | 4788 | | |
| |||
0 commit comments