Support hashing of various data types by implementing generic hashing for IValues (#46441)
Summary:
It used to be that TorchScript only supported hashing of `int`, `float` and `str`. This PR adds hashing for many other types including `Tuple`, `bool`, `device` by implementing generic hashing on IValue.
* Tensor hashing follows eager behavior, which is identity-based (hash according to pointer address rather than tensor content).
Fixes https://github.com/pytorch/pytorch/issues/44038
This is based on suo's https://github.com/pytorch/pytorch/issues/44047, with some cleaning, more tests and fixing BC check issue.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46441
Reviewed By: robieta
Differential Revision: D24440713
Pulled By: gmagogsfm
fbshipit-source-id: 851f413f99b6f65084b551383ad21e558e7cabeb