aliasing fixes (#66977)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66977
Fix for https://github.com/pytorch/pytorch/issues/47218
More context is in original PR here: https://github.com/pytorch/pytorch/pull/20556
Test Plan: Imported from OSS
Reviewed By: malfet, albanD
Differential Revision: D31935573
Pulled By: eellison
fbshipit-source-id: 3658d5711116396c35f1d5016773b0096ed347a5