-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpInfo] add reference and error inputs for multi_margin_loss
#104850
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/104850
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 945cc67: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Summary:
|
@@ -9297,7 +9297,6 @@ def v(fn): | |||
|
|||
v(lambda: F.nll_loss(input, target, reduction=reduction)) | |||
v(lambda: F.cross_entropy(input, target, reduction=reduction)) | |||
v(lambda: F.multi_margin_loss(input, target, reduction=reduction)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid reductions are tested in error inputs now.
def test_multi_margin_loss_errors(self, device): | ||
self.assertRaises(RuntimeError, | ||
lambda: nn.functional.multi_margin_loss(torch.randn(5, device=device), | ||
torch.zeros(3, device=device))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid shapes are tested in error inputs now.
for target in (torch.tensor(0, device=device), torch.tensor([0], device=device)): | ||
self.assertEqual(target.shape, torch.nn.functional.multi_margin_loss(input, target, reduction='none').shape) | ||
self.assertEqual((), torch.nn.functional.multi_margin_loss(input, target, reduction='mean').shape) | ||
self.assertEqual((), torch.nn.functional.multi_margin_loss(input, target, reduction='sum').shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid shapes/scalars were already tested in sample inputs.
…loss`" [ghstack-poisoned]
error_regex=( | ||
r'inconsistent target size, expected 5 but got \[5, 4\]' | ||
if torch.device(device).type == 'cuda' else | ||
r'inconsistent target size, got: \[5, 4\]')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error-message-divergence is fixed in the next PR in the stack.
…loss`" [ghstack-poisoned]
…loss`" [ghstack-poisoned]
Stack from ghstack:
multi_margin_loss
ops #104578multi_margin_loss
: checkweight
shape, make contiguous on CPU, add tests #104852multi_margin_loss_shape_check
on CPU and CUDA #104851multi_margin_loss
#104850