Added C++ API test (#30980)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30980
This stack is a first step toward an effort to fix, clean up and simplify code generation logic. �Please see the master [task](https://github.com/pytorch/pytorch/issues/30405) to see related discussions and all the known issues.
Main focus of these changes is TensorOptions in code generation.
Goals:
- Remove TensorOptions from generated code wherever it's possible. Leave it only in python/C++ API layers.
- Refactor TensorOptions logic to a single place.
- Log all discovered issues.
Non goals:
- Fix Everything!
- Remove all the hacks in code generation scripts.
- Clean up and defector all code generation scripts.
--------------
In this PR:
Add a test to check that C++ API behavior stays the same after all the changes.
While working on it a bug related to `requires_grad` was found and logged in the master task.
--------------
Test Plan: Imported from OSS
Differential Revision: D18912681
Pulled By: izdeby
fbshipit-source-id: 19772a37c92dde820839b79055f348689b99fa77