| 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 | |