Metadata-Version: 2.4
Name: noniml
Version: 0.1.0
Summary: Noni — a tiny tensor library with autograd, for humans.
Home-page: https://github.com/pacifio/noni
Author: Adib Mohsin
Author-email: adibmohsin.root@gmail.com
License: MIT
Project-URL: Source, https://github.com/pacifio/noni
Project-URL: Bug Reports, https://github.com/pacifio/noni/issues
Keywords: autograd,tensor,deep-learning,machine-learning,numpy,educational
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Provides-Extra: opencl
Requires-Dist: pyopencl; extra == "opencl"
Provides-Extra: all
Requires-Dist: pyopencl; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

## Noni (WIP)

<img src="./media/noni.png" height=48 />

A minimal tensor library with autograd flexible for building good enough deep learning models.

### Familiar API

```python
a = Tensor([[1., 2.], [3., 4.]], requires_grad=True)
b = Tensor([[0.5, -1.], [2., 0.]], requires_grad=True)

# Each op records its backward function
c = a * b        # op="*",  backward: dc/da = b, dc/db = a
d = c.sum()      # op="sum", backward: ones

d.backward()     # topological sort → apply each _backward in reverse

print(a.grad)    # dL/da = b.data = [[0.5, -1.], [2., 0.]]
print(b.grad)    # dL/db = a.data = [[1., 2.], [3., 4.]]
```

### Common Modules for everything

```python
from noni.nn import Linear, LayerNorm, MultiHeadAttention, CrossEntropyLoss

# A simple 2-layer MLP
W1 = Linear(784, 256)
W2 = Linear(256, 10)

x = Tensor(some_batch)
h = W1(x).relu()
logits = W2(h)

loss = CrossEntropyLoss()(logits, targets)
loss.backward()   # gradients in W1.weight.grad, W2.weight.grad etc.
```

### Build your own

Noni has opencl for gpu and numpy (cpu) backends and there is work going on to support CUDA natively as well as vulkan compute and triton, but you can always implement
and register your own backend if you prefer.

```python
from noni.backends import Backend, register_backend


class MyDevice(Backend):
	...

register_backend("mygpu", MyDevice())
```

| Module                 | Description                                                                                   |
| ---------------------- | --------------------------------------------------------------------------------------------- |
| **Linear**             | Fully connected layer with weight + bias parameters, initialized using Kaiming initialization |
| **Embedding**          | Lookup table for token embeddings with scatter-add backward pass                              |
| **LayerNorm**          | Normalizes across the last N dimensions with learned affine parameters                        |
| **Dropout**            | Inverted dropout applied during training for regularization                                   |
| **MultiHeadAttention** | Multi-head self-attention module with optional causal mask for autoregressive models          |
| **FeedForward**        | Position-wise feedforward network using GELU activation                                       |
| **TransformerBlock**   | Pre-norm residual block combining Multi-Head Attention and FeedForward layers                 |
| **CrossEntropyLoss**   | Numerically stable implementation using log-softmax + negative log likelihood                 |
| **Optimizers**         | Includes SGD, Adam, AdamW, and CosineAnnealingLR scheduler                                    |

### Building wheels

```bash
python -m build
twine upload --repository testpypi dist/*
twine upload dist/*
```
