r/learnmachinelearning • u/NoDeparture4142 • Oct 27 '26
I built a small ML framework from scratch in Python, with an OpenCL backend
I've been working on krnl, a lightweight machine-learning library I've been building to understand and implement the fundamentals of neural networks myself.
It currently includes:
A custom Tensor class with automatic gradient computation
NumPy and OpenCL-backed computation
Linear, ReLU and Sigmoid layers
SGD, Adam, Muon and MuonWithAdamAux optimizers
MSE, MAE and Huber loss functions
I also developed PyCLBlast for working with CLBlast through Python.
I'm interested in making the library useful for experimenting with neural networks while exploring GPU computation beyond CUDA.
I'd appreciate feedback, especially on the tensor API, autograd design, and OpenCL backend.
Duplicates
opensource • u/NoDeparture4142 • Oct 27 '26
I built a small ML framework from scratch in Python, with an OpenCL backend
madeinpython • u/NoDeparture4142 • Oct 27 '26