https://github.com/oniani/miniml
A minimal ML library with OpenCL GPU support
https://github.com/oniani/miniml
Last synced: 25 days ago
JSON representation
A minimal ML library with OpenCL GPU support
- Host: GitHub
- URL: https://github.com/oniani/miniml
- Owner: oniani
- License: mit
- Created: 2020-11-20T11:56:17.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-04T02:15:14.000Z (about 5 years ago)
- Last Synced: 2025-11-09T14:27:21.586Z (9 months ago)
- Language: Python
- Homepage:
- Size: 89.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
⚠
The project is under development. Some core features (e.g., GPU array
broadcasting) are yet to be implemented.
# miniml
A minimal ML library with OpenCL GPU support.
## Perf
| Category | CPU | GPU | Perf Boost |
| --------- | ----- | ----- | ---------- |
| `rand` | 0.747 | 0.002 | 37X |
| `uniform` | 0.820 | 0.002 | 41X |
| `normal` | 1.829 | 0.002 | 91X |
## Features
### Activation Functions
- [x] ReLU
- [x] LeakyReLU
- [x] Tanh
- [x] Sigmoid
- [ ] Softmax
- [ ] LogSoftmax
### Tensor
Most important operations are implemented. They work on both CPU and GPU.
The API is very simple:
```python
import miniml.tensor as T
# Initialize a CPU tensor
t1 = T.Tensor([1, 2, 3])
# Initialize a GPU tensor
t2 = T.Tensor([1, 2, 3], gpu=True)
# Load the GPU tensor onto the CPU
t2 = t2.to_cpu()
# Load it back onto the GPU
t2 = t2.to_gpu()
```
CPU tensors use NumPy operations and the GPU tensors use PyOpenCL
operations.
## Tests
```console
python3 -m pytest -sv
```
---
TODO:
- Implement a reverse-mode automatic differentiation
- Implement network layers
- Implement loss function(s?)
- Implement Adam optimizer
- More tests (maybe use a monadic test-generator like Hypothesis?)
## References
- [NumPy](https://numpy.org/)
- [OpenCL](https://www.khronos.org/opencl/)
- [PyOpenCL](https://documen.tician.de/pyopencl/index.html)
## License
[MIT License](LICENSE)