[PyTorch] Avoid extra intrusive_ptr copy in IValue::toIntrusivePtr (#54124)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54124
No need to have an extra temporary intrusive_ptr (`p`) just to do an `incref`.
ghstack-source-id: 124150644
Test Plan:
existing tests for correctness; inspect assembly for
c10::IValue::toObject to double-check & see that it's a bit shorter
Reviewed By: smessmer
Differential Revision: D27109183
fbshipit-source-id: 497706190867eeac0fb1d309d0ecc97cf8d65b08