Back to Architecture Explorer

pytorch / pytorch

Tensors and dynamic neural networks in Python with strong GPU acceleration.

84.0k
Python / C++
Architecture: framework
main
pytorch
torch
nn
optim
autograd
csrc
distributed
aten
src
c10
caffe2
test
tools
docs
setup.py
Structural Architecture

PyTorch is a layered hybrid: a Python surface that users import, sitting on top of a substantial C++ core. The directory layout follows that division closely, separating the tensor library, the low-level core abstractions, and the Python bindings so each layer can be built and tested independently.

  • Strict layering, with each language boundary given its own top-level directory.
  • Generated binding code produced at build time rather than committed.
  • Tests kept in a single top-level directory rather than colocated per module.

Notable Directories

/torch

The Python package users import, including bindings down into the C++ layers.

/aten

ATen, the C++ tensor library providing the underlying operator implementations.

/c10

Core abstractions shared across the codebase, such as device and dtype primitives.

/tools

Code generation and build tooling that stitches the C++ and Python layers together.

Build Your Own Ecosystem

Learn from pytorch's structure and craft your own software scaffolding.