Conversation
💊 CircleCI build failures summary and remediationsAs of commit e168911 (more details on the Dr. CI page): ✅ None of the build failures appear to be your fault 💚
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker. This comment has been revised 33 times. |
| @float_double_default_dtype | ||
| def test_true_divide(self, device, dtype): | ||
| dividend = torch.randn(5, device=device).to(dtype) | ||
| dividend = (torch.randn(5, device=device) * 100).to(dtype) |
There was a problem hiding this comment.
why do you multiply by 100?
There was a problem hiding this comment.
To make the division more interesting. Example dividends:
(torch.randn(100)).long()
: tensor([ 0, 0, -1, -2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0,
1, -1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 1, 0, 0, 1, 0,
0, 1, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, 0, -1, 0, 0, -2, 0,
0, 0, 1, -1, 0, 0, -1, 0, 0, 0, 0, -1, 1, 0, 0, 0, -1, -1,
0, 0, -1, -1, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 1, -1, 0, 0, 1, 0, 1])
(torch.randn(100) * 100).long()
: tensor([ 54, 113, 7, 69, 4, 98, -32, 223, -36, 285, -111, -6,
-36, -43, 122, -39, -164, 101, -100, -122, -2, -70, 40, 121,
16, 21, 6, 21, -110, -35, -186, 193, 15, -21, 75, 61,
-62, -27, -116, -32, -17, -159, -111, 56, -28, 59, -117, 63,
-57, -49, 210, 93, 11, -107, -66, 32, -8, -150, -20, 46,
6, 98, -28, 87, 6, -124, -81, 42, -68, -14, -39, -149,
117, 48, -81, -120, -138, 183, 146, -43, -72, -53, -93, 67,
-73, -161, 152, 57, -229, -37, 59, -85, 47, 178, -127, -110,
34, 175, -11, -39])
| @dtypes(torch.float, torch.double, torch.bool, torch.short, torch.uint8, torch.int, torch.long) | ||
| def test_true_divide_out(self, device, dtype): | ||
| dividend = torch.randn(5, device=device).to(dtype) | ||
| dividend = (torch.randn(5, device=device) * 100).to(dtype) |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Per title. See related pytorch#34570. In PyTorch 1.7 the plan is for torch.div and Python's division operator to perform "true" division, like Python 3, JAX, and NumPy. To facilitate this change, this PR expands true_divide to be a method so it can cover all of torch.div's use cases. New true_divide tests are added to test_torch.py, test_type_promotion.py, and test_sparse.py. Pull Request resolved: pytorch#34794 Differential Revision: D20545507 Pulled By: mruberry fbshipit-source-id: 55286f819716c8823d1930441a69008560ac2bd5
Per title. See related #34570.
In PyTorch 1.7 the plan is for torch.div and Python's division operator to perform "true" division, like Python 3, JAX, and NumPy. To facilitate this change, this PR expands true_divide to be a method so it can cover all of torch.div's use cases.
New true_divide tests are added to test_torch.py, test_type_promotion.py, and test_sparse.py.