PyTorch Developer Podcast
PyTorch Developer Podcast
Edward Yang, Team PyTorch
Multiple dispatch in __torch_function__
14 minutes Posted Aug 10, 2021 at 1:00 pm.
0:00
14:20
Download MP3
Show notes

Python is a single dispatch OO language, but there are some operations such as binary magic methods which implement a simple form of multiple dispatch. torch_function__ (through its Numpy predecessor __array_function) generalizes this mechanism so that invocations of torch.add with different subclasses work properly. This podcast describes how this mechanism works and how it can be used (in an unconventional way) to build composable subclasses ala JAX in functorch.

Further reading: