File size: 1,536 Bytes
5334ac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
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