File size: 439 Bytes
ff90a24
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import torch
from safetensors.torch import load_file

def load_model(path='model.safetensors'):
    return load_file(path)

if __name__ == '__main__':
    w = load_model()
    print('Absolute Value 4-bit (2\'s complement):')
    print('Input  Signed  |Abs|  Output')
    for a in range(16):
        signed = a if a < 8 else a - 16
        expected = abs(signed)
        print(f' {a:04b}   {signed:+2d}      {expected}     {expected:04b}')