본문 바로가기

전체 글100

[VLSI] Very Large Scale Integraed Circuit * Understanding basic operations for computer arithmetic * Understanding signal processing techniques for VLSI architectures ◆ DSP system, Iteration bound ◆ Pipelining and parallel processing ◆ Retiming and unfolding technique ◆ Folding technique ◆ Conventional and unconventional number systems, Fast addition ◆ Binary floating-point number system ◆ Sequential algorithms for multiplication and di.. 2023. 12. 31.
[Python] register file의 address 값 - csv 파일에 저장하는 법 import pandas as pd import numpy as np import torch net: nafnet_v0 save_wgt: True save_io: True rf_info: ./rtl_verif/rf_id.csv csv_path: ./rtl_verif/other_params.csv def __init__(self, cfg, index): self.set_register_file() def set_register_file(self): df = pd.read_csv(self.params.rf_info) for name, mod in self.net.named_modules(): cls_name = mod.__class__.__name__# Conv2d와 같은 상위 레이어 mod.name = n.. 2023. 9. 18.
[Python] DNN 안의 parameter를 .csv 파일에 저장하는 법 utils/monitor.py class Singletone(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls._instances: cls._instances[cls] = super(Singletone, cls).__call__(*args, **kwargs) return cls._instances[cls] class Monitor(metaclass=Singletone): def __init__(self, csv_path, save_io=False, save_wgt=False, save_qa=True): self.csv_path = csv_path self.save_io = save_io self.save_wgt = s.. 2023. 9. 18.
[Python] Quantization - scaler 값 integer로 변환 Python코드로 Quantization - scaler 값 integer로 변환하기 Scaler = 0.0000296831131 Scaler = np.round(Scaler*(2**24)) # Scaler를 24bit로 표현 print(Scaler) 해당 값이 498로 출력된다. 근데 Scaler를 아래 변환기로 직접 계산해보면 496으로 오차가 발생한다. Scaler를 binary로 표현하면 21bit으로 가능하고, 현재 24bit으로 통일하여 맞추고 싶으므로 binary 값에 LSB 3bit을 0으로 채우면 decimal로 496이 나온다. decimal to binary 변환에서 오차가 발생하는 것으로 보인다. 2023. 9. 18.
[Python] .npy to .mem 파일 변환 Python코드로 .npy to .mem 파일 변환하는 방법 import numpy as np from fxpmath import Fxp layer_name = 'ending.resq' # load .npy file inp1 = np.load(f'./rtl_test/{layer_name}_inp0.npy') # Total data length: 16bit, fraction bit: 0bit, signed inp1_fxp = Fxp(inp1, n_word=16, n_frac=0, signed=True) # save to .mem file with open(f'memfile/{layer_name}_inp0_split0.mem', 'w') as f: for v in inp1_fxp.flatten().bin().. 2023. 9. 18.
[Verilog] Fixed point Scaler 연산 (Sign 연산 - right shift) verilog에서 shift는 4가지 형태로 존재한다. >>, >, 2; //c == 5'b11101, 'cause sign bit was `1` d = a >> 3을 했는데 sign bit으로 채워지지 않는 걸 발견했다. 보아 하니 a가 signed으로 casting 되어 있어야 했다. reg signed [9:0] b = 10'sb11_0101_0101; reg signed [9:0] a_signed; reg [9:0] a_unsigned; always_comb begin a_signed = b >>> 2; a_unsigned = b >> 2; end #a_signed 1111010101 #a_unsigned 0011010101 혹은 연산할 때 casting 방식으로 wire [PSUM_WL+SCAL.. 2023. 9. 9.
[Python] 3x3 depthwise convolution 코드 # loading the layer file layer_name = 'intro.conv1.convs.2' inp = np.load(f'npy/{layer_name}_inp.npy') wgt = np.load(f'npy/{layer_name}_wgt.npy') try: bias = np.load(f'npy/{layer_name}_bias.npy') except: bias_flag = False else: bias_flag = True out = np.load(f'npy/{layer_name}_out.npy') # mapping fixed point inp_fxp = inp.astype(np.int64) wgt_fxp = wgt.astype(np.int64) psum_fxp = np.zeros_like(o.. 2023. 9. 9.
[Python] 1x1 point convolution 코드 # loading the layer file layer_name = 'intro.conv1.convs.1' inp = np.load(f'npy/{layer_name}_inp.npy') wgt = np.load(f'npy/{layer_name}_wgt.npy') try: bias = np.load(f'npy/{layer_name}_bias.npy') except: bias_flag = False else: bias_flag = True out = np.load(f'npy/{layer_name}_out.npy') # changing to fixed point inp_fxp = inp.astype(np.int64) wgt_fxp = wgt.astype(np.int64) psum_fxp = np.zeros_li.. 2023. 9. 9.