File size: 920 Bytes
5d5afcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
---

# threshold-max2

Maximum of two 2-bit unsigned integers.

## Function

max2(a, b) = max(a, b) where a, b are 2-bit unsigned (0-3)

## Truth Table (selected)

| a | b | max(a,b) |
|---|---|----------|
| 0 | 0 | 0 |
| 1 | 2 | 2 |
| 2 | 1 | 2 |
| 3 | 3 | 3 |
| 0 | 3 | 3 |
| 3 | 0 | 3 |

## Architecture

7-layer circuit:
1. Compare high bits, compare low bits
2. Compute a1 == b1
3. Compute partial comparison results
4. Compute a > b, a == b
5. Compute a >= b
6. MUX components
7. Final output selection

## Parameters

| | |
|---|---|
| Inputs | 4 (a1, a0, b1, b0) |
| Outputs | 2 (m1, m0) |
| Neurons | 31 |
| Layers | 7 |
| Parameters | 180 |
| Magnitude | 96 |

## Usage

```python
from safetensors.torch import load_file

w = load_file('model.safetensors')
# See create_safetensors.py for full implementation
```

## License

MIT