[testing] OpInfoHelper tool (#58698)
Summary:
Fixes: https://github.com/pytorch/pytorch/issues/57577
Usage:
Add OpInfo entry to `common_methods_invocations` with `dtypes=_DYNAMIC_DYTPES`
Eg.
```
OpInfo('atan2',
dtypes=_DYNAMIC_DTYPES,
sample_inputs_func=sample_inputs_atan2,)
```
Run the helper with `python -m torch.testing._internal.opinfo_helper`
Output
```
OpInfo(atan2,
# hint: all_types + (torch.bool,),
dtypes=[torch.float32, torch.float64, torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64, torch.bool],
# hint: all_types + (torch.bool, torch.bfloat16, torch.float16),
dtypesIfCUDA=[torch.float32, torch.float64, torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64, torch.bool, torch.bfloat16, torch.float16],
sample_inputs_func=sample_inputs_atan2)
```
Output without CUDA (run with `$ CUDA_VISIBLE_DEVICES=-1 python -m torch.testing._internal.opinfo_helper`)
```
UserWarning: WARNING: CUDA is not available, information pertaining to CUDA could be wrong
warnings.warn("WARNING: CUDA is not available, information pertaining to CUDA could be wrong")
OpInfo(atan2,
# hint: all_types + (torch.bool,),
dtypes=[torch.float32, torch.float64, torch.uint8, torch.int8, torch.int16, torch.int32, torch.int64, torch.bool],
sample_inputs_func=sample_inputs_atan2)
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/58698
Reviewed By: H-Huang
Differential Revision: D29160668
Pulled By: mruberry
fbshipit-source-id: 707370a83b451b02ad2fe539775c8c50ecf90be8