Skip to content

Instantly share code, notes, and snippets.

A Tour of PyTorch Internals (Part I)

The fundamental unit in PyTorch is the Tensor. This post will serve as an overview for how we implement Tensors in PyTorch, such that the user can interact with it from the Python shell. In particular, we want to answer four main questions:

  1. How does PyTorch extend the Python interpreter to define a Tensor type that can be manipulated from Python code?
  2. How does PyTorch wrap the C libraries that actually define the Tensor's properties and methods?
  3. How does PyTorch cwrap work to generate code for Tensor methods?
  4. How does PyTorch's build system take all of these components to compile and generate a workable application?

Extending the Python Interpreter

PyTorch defines a new package torch. In this post we will consider the ._C module. This module is known as an "extension module" - a Python module written in C. Such modules allow us to define new built-in object types (e.g. the Tensor) and to call C/C++ functions.

@ntustison
ntustison / a_background.md
Last active November 17, 2024 20:13
ANTsX Tutorial

ANTs intro

  • ANTs --- Set of C++ programs built on top of the Insight Toolkit
  • ANTsR --- R-based ANTs interface (dependencies include ITKR, ANTsRCore)
  • ANTsPy --- Python-based ANTs interface
  • ANTsXNet --- deep learning library built on Keras
    • ANTsRNet
  • ANTsPyNet