Re:Minitorch: Implement the Torch API from Scratch, from Cor...
by lostmsu on Tuesday January 11, 2022 @01:01PM
(#29895115)
They must be doing something else with numpy as Python has a generic API, that allows direct access to data of numpy array-like structures: Buffer Protocol https://docs.python.org/3/c-api/buffer.html
[ Parent
| on HN ]
Re:Minitorch: Implement the Torch API from Scratch, from Cor...
by p1esk on Tuesday January 11, 2022 @03:10PM
(#29897121)
It’s not just about access to underlying data - users might want to import from, or export to numpy array (e.g. for visualization, etc).
Re:Minitorch: Implement the Torch API from Scratch, from Cor...
by lostmsu on Tuesday January 11, 2022 @11:33PM
(#29902342)
Buffer protocol means PyTorch can have a torch.tensor method, that can create a tensor of anything implementing this protocol (which NumPy arrays do), and likewise numpy.array can be constructed out of PyTorch array because PyTorch Tensor implements this protocol. E.g. they don't need to know about each other (so no dependency), only about the protocol.