hardswish: add backards pass test#36420
Conversation
Summary: Adds a unit test for hardswish backward pass Test Plan: Unit test passes on cpu and cuda Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
💊 Build failures summary and remediationsAs of commit 6c033d5 (more details on the Dr. CI page):
🕵️ 2 new failures recognized by patternsThe following build failures do not appear to be due to upstream breakages:
|
| def test_hardswish_grad(self, device): | ||
| inputs = (torch.randn(4, 16, 16, device=device) - 0.5) * 10 | ||
| inputs.requires_grad = True | ||
| self.assertTrue(gradcheck(F.hardswish, (inputs,))) |
There was a problem hiding this comment.
How does this work? Where is the reference output provided here?
There was a problem hiding this comment.
this is a nice util function, it checks that the gradient computed analytically by perturbing the input matches the gradient defined by the backwards pass. It's used to test other backwards passes in this file.
pytorch/torch/autograd/gradcheck.py
Line 198 in 73a36a4
Summary: Adds a unit test for hardswish backward pass Test Plan: Unit test passes on cpu and cuda Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D20994100](https://our.internmc.facebook.com/intern/diff/D20994100) [ghstack-poisoned]
Summary: Adds a unit test for hardswish backward pass Test Plan: Unit test passes on cpu and cuda Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D20994100](https://our.internmc.facebook.com/intern/diff/D20994100) [ghstack-poisoned]
|
This pull request has been merged in 3c8921b. |
Summary: Pull Request resolved: pytorch#36420 Adds a unit test for hardswish backward pass Test Plan: Unit test passes on cpu and cuda Imported from OSS Differential Revision: D20994100 fbshipit-source-id: 579df709cc2d92fce3b9a0eeb6faeb9fe8d2f641
Stack from ghstack:
Summary:
Adds a unit test for hardswish backward pass
Test Plan:
Unit test passes on cpu and cuda
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D20994100