PyTorch Developer Podcast
PyTorch Developer Podcast
Edward Yang, Team PyTorch
Reference counting
15 minutes Posted Jul 20, 2021 at 1:00 pm.
0:00
15:14
Download MP3
Show notes

Reference counting is a common memory management technique in C++ but PyTorch does its reference counting in a slightly idiosyncratic way using intrusive_ptr. We'll talk about why intrusive_ptr exists, the reason why refcount bumps are slow in C++ (but not in Python), what's up with const Tensor& everywhere, why the const is a lie and how TensorRef lets you create a const Tensor& from a TensorImpl* without needing to bump your reference count.

Further reading.