Live data from Hacker News

Minitorch: Implement the Torch API from Scratch, from Cornell Tech

minitorch.github.io

21–22 of 22 posts

Re: Minitorch: Implement the Torch API from Scratch, from Cornell Tech

#21
post #20
post #18

Earlier quoted context omitted.

It does, because it can convert a numpy array to a pytorch tensor and back, but I don’t think numpy is used for anything else.

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

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 Cornell Tech

#22
post #21
post #20

Earlier quoted context omitted.

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

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).

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.
Post reply on HN