Define toIValue conversion for dtype (#23708)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/23708
Resolves https://github.com/pytorch/pytorch/issues/23631
We always treat dtypes as number types, and we have the conversion logic of dtype->int64_t present in toSugaredValue. So if a dtype appears in a statement being compiled, it's properly converted to its long ScalarType equivalent. However, this logic was missing in `toIValue`, thus making taking dtypes as attributes broken
Test Plan: Imported from OSS
Differential Revision: D16617222
Pulled By: jamesr66a
fbshipit-source-id: 4b10e5795f9c142c2fd9fa1b5d60f6374f5218e0