bugfix for conditional functionalization (#67715)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/67715
I had original made the `vector<ViewMeta>` and `Tensor`s stored on the `Update` struct references, but will pointed out a bug in the conditional-functionalization PR due to a use-after-free error. This happens because the queued-up updates might not be synced until later, and can out-live the original tensor that was used to create them.
It was kind of strange that this doesn't show up in the existing `test/test_functionalization.py` tests that I have in this stack, which technically also should have this bug (they call sync_() after the mutated tensors have gone out of scope). I looked at it with gdb, and I'm wondering if it's just because the stored values in the free'd `ViewMeta`/`Tensor` just happen to not get clobbered by the time the sync is called in the test.
Either way, copying the Tensor + vector<ViewMeta> is probably not ideal for performance, but I couldn't think of an easy work-around for now.
Test Plan: Imported from OSS
Reviewed By: malfet
Differential Revision: D32136007
Pulled By: bdhirsh
fbshipit-source-id: 707c6392a31b967e8965b9b77f297fd10a0a095a