How a1henu/tinytorch works
Project type and purpose
• This is a tiny deep-learning framework implemented in C++ with Python bindings (“tinytorch”).
• It provides core tensor computations (CPU/GPU), layers (conv, pooling, FC, loss), and automatic differentiation, exposed to Python via pybind11.
• It includes examples for CIFAR-10, MNIST, ImageNet; unit tests in C++ (GoogleTest) and Python (pytest); build and CI scripts.
File structure
• Top-level directories
• csrc/ – C++ source tree
· core/ (device management, memory, low-level kernels)
· tensor/ (tensor class, operators)
· layers/ (layer implementations, bindings)
· error/ (error definitions)
· CMakeLists.txt, macros.h
• tinytorch/ – Python package
· autodiff.py, tensorbase.py, tensor.py
· data/ (datasets, data loaders)
· funcs/ (functional API, auto-diff)
· nn/ (Module classes, activations, loss, optimizers)
· node.py, operators.py, optim/
• examples/ – sample training scripts
• tests/ – pytest suites
• scripts/ – build/test/clean helpers
• third_party/ – googletest, pybind11
• CI configs (.github/workflows)
• Patterns
• Layered design: core C++ engine → pybind11 binding → Python API
• CPU/GPU abstraction: in core/kernels and core/device
• Modular structure: separate folders per concern
• Build/test orchestration via CMake + shell scripts + GitHub Actions
README for additional insights
• Confirms use of OpenBLAS, optional CUDA
• Installation steps for C++ build (CMake), Python packaging (pip install)
• Testing workflows (GoogleTest, pytest)