TinyAutoGrad is an automatic differentiation engine and neural network library inspired by Micrograd, with optional CUDA support.
- ⚙️ Automatic differentiation (forward & backward)
- 🧱 Simple
Tensorclass with NumPy-style operations - 🧠 Neural network support with MLP example
- 💻 CPU and ⚡ CUDA backend support
- 🧪 Built-in testing with
pytest
Run the MNIST example on CPU:
python -m samples.mnist.mnistEnsure CUDA toolkit (nvcc) is installed:
# Compile CUDA backend
nvcc -shared -o libops.so tinyautograd/ops.cu -Xcompiler -fPIC -lcublas
# Run test.py
python test.py
# Run MNIST with CUDA backend
python -m samples.mnist.mnist_cuda
⚠️ Make surelibops.sois in the current directory or Python load path.
Run all unit tests:
pytest tinyautograd/ -s -v --cache-clearOr a specific test:
pytest tinyautograd/test_rawtensor.py -s -v --cache-clear.
├── README.md
├── libops.so
├── test.py
├── samples
│ └── mnist
│ ├── mnist.py
│ ├── mnist_cuda.py
│ ├── train-images-idx3-ubyte.gz
│ └── train-labels-idx1-ubyte.gz
├── tinyautograd
│ ├── __init__.py
│ ├── functional.py
│ ├── nn.py
│ ├── ops.cu
│ ├── optim.py
│ ├── rawtensor.py
│ ├── tensor.py
│ ├── test_nn.py
│ ├── test_rawtensor.py
│ └── test_tensor.py
MIT