|
|
--- |
|
|
license: mit |
|
|
tags: |
|
|
- pytorch |
|
|
- safetensors |
|
|
- threshold-logic |
|
|
- neuromorphic |
|
|
--- |
|
|
|
|
|
# threshold-buffer |
|
|
|
|
|
4-bit buffer (identity function). Passes input through unchanged. |
|
|
|
|
|
## Function |
|
|
|
|
|
buffer4(x3, x2, x1, x0) -> (y3, y2, y1, y0) |
|
|
|
|
|
Output equals input: y_i = x_i for all i. |
|
|
|
|
|
## Truth Table |
|
|
|
|
|
| Input | Output | |
|
|
|-------|--------| |
|
|
| 0000 | 0000 | |
|
|
| 0001 | 0001 | |
|
|
| ... | ... | |
|
|
| 1111 | 1111 | |
|
|
|
|
|
## Architecture |
|
|
|
|
|
Single-layer, each output independently buffers one input: |
|
|
|
|
|
``` |
|
|
x3 x2 x1 x0 |
|
|
│ │ │ │ |
|
|
â–¼ â–¼ â–¼ â–¼ |
|
|
â—‹ â—‹ â—‹ â—‹ Layer 1 |
|
|
│ │ │ │ |
|
|
â–¼ â–¼ â–¼ â–¼ |
|
|
y3 y2 y1 y0 |
|
|
``` |
|
|
|
|
|
Each neuron: w=[...,1,...], b=-1 (single input with weight 1). |
|
|
|
|
|
## Parameters |
|
|
|
|
|
| | | |
|
|
|---|---| |
|
|
| Inputs | 4 | |
|
|
| Outputs | 4 | |
|
|
| Neurons | 4 | |
|
|
| Layers | 1 | |
|
|
| Parameters | 20 | |
|
|
| Magnitude | 8 | |
|
|
|
|
|
## Purpose |
|
|
|
|
|
While trivial, buffers serve several purposes: |
|
|
- Signal regeneration in long chains |
|
|
- Fan-out amplification |
|
|
- Timing alignment |
|
|
- Isolation between circuit stages |
|
|
|
|
|
## Usage |
|
|
|
|
|
```python |
|
|
from safetensors.torch import load_file |
|
|
import torch |
|
|
|
|
|
w = load_file('model.safetensors') |
|
|
|
|
|
def buffer(x3, x2, x1, x0): |
|
|
inp = torch.tensor([float(x3), float(x2), float(x1), float(x0)]) |
|
|
y0 = int((inp @ w['y0.weight'].T + w['y0.bias'] >= 0).item()) |
|
|
y1 = int((inp @ w['y1.weight'].T + w['y1.bias'] >= 0).item()) |
|
|
y2 = int((inp @ w['y2.weight'].T + w['y2.bias'] >= 0).item()) |
|
|
y3 = int((inp @ w['y3.weight'].T + w['y3.bias'] >= 0).item()) |
|
|
return y3, y2, y1, y0 |
|
|
``` |
|
|
|
|
|
## License |
|
|
|
|
|
MIT |
|
|
|