--- license: mit tags: - pytorch - safetensors - threshold-logic - neuromorphic - comparison --- # threshold-lessthan 8-bit less-than comparator. Returns 1 if a < b, 0 otherwise. ## Circuit ``` a0 b0 a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 │ │ 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ └┬┘│ └┬┘ └┬┘ └┬┘ └┬┘ └┬┘ └┬┘ └┬┘ ▼ │ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ┌───┐│ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │FS0│┴──│FS1│────│FS2│────│FS3│────│FS4│────│FS5│────│FS6│────│FS7│──►(a b | LessThan(b, a) | ## Usage ```python from safetensors.torch import load_file w = load_file('model.safetensors') def less_than(a, b): """a, b: 8-bit lists [a0..a7] (LSB first) Returns: 1 if a < b, 0 otherwise""" # See model.py for full implementation pass # Example: 99 < 100? a = [(99 >> i) & 1 for i in range(8)] b = [(100 >> i) & 1 for i in range(8)] result = less_than(a, b) # Returns 1 ``` ## Files ``` threshold-lessthan/ ├── model.safetensors ├── model.py ├── config.json └── README.md ``` ## License MIT