Generalize IValue's aliased hash handling for opaque tensors (#70371)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/70371
This PR generalizes the aliased hash handling for opaque tensors beyond MKL-DNN.
ghstack-source-id: 147328304
Test Plan: Run existing tests.
Reviewed By: zou3519
Differential Revision: D33301787
fbshipit-source-id: db741ac347e933f8d65b029cd5be5f01804a960e
(cherry picked from commit aa8822a31a1002ea0c2440041e5e8cb862666535)