Refactor and improve AOTAutograd tests (#103197)
This is in preparation for the new "custom_op_compile_check" utility,
which will call the refactored testing API as a subroutine.
Here are the improvements to the AOTAutograd tests that this PR makes:
- we use torch.autograd.grad instead of .backward(), which makes it so
that we stop destructively modifying the inputs
- we get rid of the difficult-to-understand sentinel=42 logic and
replace it with something more sane
- We create some helper functions and add some code comments
- We improve error messages
Test Plan:
- wait for CI
Pull Request resolved: https://github.com/pytorch/pytorch/pull/103197
Approved by: https://github.com/bdhirsh, https://github.com/soulitzer, https://github.com/Chillee