reland fast TypeMeta/ScalarType conversion (#45544)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/45544
Test Plan: Imported from OSS
Reviewed By: ezyang
Differential Revision: D24006482
Pulled By: bhosmer
fbshipit-source-id: 5da2401ab40bbf58da27a5d969e00bcee7562ed6