Python prototype and scripts to generate simulation data. (原谅我英语很差, 一堆语法错)
# feature map - python simulation
python data_convert.py \
--dir fmap_dat \
--filename base_4_56_f.dat \
--in_shape 4 1 1 56 \
--convert_shape 0 1 2 3 4 \
--output base_4_56.dat
# weight - python simulation
python data_convert.py \
--dir weight_dat \
--filename base_4_3_3_f.dat \
--in_shape 4 1 3 3 \
--convert_shape 0 1 2 3 4 \
--quantize shift \
--quantize_integer 4 \
--quantize_bitwidth 4 \
--output base_4_3_3.dat
# feature map - modelsim simulation
python data_convert.py \
--dir fmap_dat \
--filename base_4_56_f.dat \
--in_shape 4 1 1 56 \
--paral 4 \
--convert_shape 2 4 0 1 3 \
--output base_4_56.txt \
--sim_paral 4 \
--txt
# weight - modelsim simulation
python data_convert.py \
--dir weight_dat \
--filename base_4_3_3_f.dat \
--in_shape 4 1 3 3 \
--paral 4 \
--convert_shape 0 4 1 2 3 \
--quantize shift \
--quantize_integer 4 \
--quantize_bitwidth 4 \
--output base_4_3_3.txt \
--sim_paral 4 \
--txt
# feature map - on board test
python data_convert.py \
--dir fmap_dat \
--filename base_4_56_f.dat \
--in_shape 4 1 1 56 \
--paral 4 \
--convert_shape 2 4 0 1 3 \
--output base_4_56_p.dat
# conv.py
python conv.py \
--fmap base_4_56.dat \
--fmap_shape 4 56 \
--weight base_4_3_3.dat \
--weight_shape 4 3 3 \
--out base_4_3_58.datThe original data is float32 and stored into binary file. The filename of the original data will be end with 'f'.
The modelsim simulation data is integer and is stored into text file as hexadecimal.
The python simulation data is integer and is stored into text file as hexadecimal.
Data for on-board test is integer and is stored into binary file.
Example:
base_4_56_f.datis original filename template.base_4_56.txtis modelsim simulation filename template.base_4_56.datis python simulation filename template.base_4_56_p.datis on-board filename template.
Generate corresponding data from original data with data_convert.py.
Detailed data format:
The original feature map data layout (4D):
( channels, 1, row, column )
The original weight data layout (4D):
( out_channel, in_channel, row, col )
The on-board test feature map data layout (5D):
( 1, row, channel/paral, column, paral )
The on-board test weight data layout (5D):
( out_channel/paral, in_channel, row, col, paral )Data is generated as float and stored into binary file.
It is the script that quantize data (feature map or weight) and store data into text file for simulation or store data into binary file for on-board test.
Simulate computation process of PE_cluster.v. Take original data as input. The bit-width of the feature map is 8 bits and the bit-width of the weights is 4. Adopt shift as convolution operator.
| bit width | domain | shape | |
|---|---|---|---|
| feature map, x | 8 | ||
| weight,w | 4 |
For the shift network:
- The activation value is represented by a normal form.
- The weight part is currently shifted to the right uniformly, and the sign indicates whether to take the complement or not, which means, the sign bit and the value bit represent operations at different positions.
For example,