Fix contiguous AD and Autogradzero inconsistency (#18633)
Summary:
Fixes #17962
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18633
Differential Revision: D14700449
Pulled By: wanchaol
fbshipit-source-id: 3d15d67c01b69b28394a0f2f001db90ed9fd31dc