Commit 8734b17
Multinomial raise error (#12490)
Summary:
Fixes #12260 #2896
```
torch.multinomial(torch.FloatTensor([0, 1, 0, 0]), 3, replacement=False)
```
The old behavior is that we return `0` after we run out of postive categories. Now we raise an error based on discussion in the issue thread.
- Add testcase for cpu & cuda case, in cuda case `n_samples=1` is a simple special case, so we test against `n_sample=2` instead.
Pull Request resolved: #12490
Differential Revision: D10278794
Pulled By: ailzhang
fbshipit-source-id: d04de7a60f60d0c0d648b975db3f3961fcf42db11 parent b89a3b5 commit 8734b17
File tree
4 files changed
+24
-22
lines changed- aten/src
- THC
- TH/generic
- test
4 files changed
+24
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
| |||
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
303 | 307 | | |
304 | 308 | | |
305 | 309 | | |
| |||
310 | 314 | | |
311 | 315 | | |
312 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
313 | 321 | | |
314 | 322 | | |
315 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1594 | 1594 | | |
1595 | 1595 | | |
1596 | 1596 | | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | 1597 | | |
1609 | 1598 | | |
1610 | 1599 | | |
| |||
1621 | 1610 | | |
1622 | 1611 | | |
1623 | 1612 | | |
1624 | | - | |
| 1613 | + | |
1625 | 1614 | | |
1626 | 1615 | | |
1627 | 1616 | | |
| |||
1635 | 1624 | | |
1636 | 1625 | | |
1637 | 1626 | | |
1638 | | - | |
1639 | | - | |
1640 | | - | |
1641 | | - | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
1642 | 1632 | | |
1643 | 1633 | | |
1644 | 1634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2851 | 2851 | | |
2852 | 2852 | | |
2853 | 2853 | | |
2854 | | - | |
| 2854 | + | |
| 2855 | + | |
2855 | 2856 | | |
2856 | 2857 | | |
2857 | 2858 | | |
| |||
2864 | 2865 | | |
2865 | 2866 | | |
2866 | 2867 | | |
2867 | | - | |
2868 | | - | |
2869 | | - | |
2870 | | - | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
2871 | 2873 | | |
2872 | 2874 | | |
2873 | 2875 | | |
| |||
0 commit comments