available_registers = [['B', 'C', 'D', 'E'], ['B', 'C', 'D', 'E'],
                       ['B', 'C', 'D', 'E']]
filename_prefix = '_out_conv_'

for k in range(3):
    csimProgram, _, _ = generate(kernels[k],
                                 search_time,
                                 start_reg=start_register[k],
                                 target_reg=start_register[k],
                                 available_regs=[start_register[k]] +
                                 available_registers[k],
                                 verbose=0,
                                 out_format='CSIM',
                                 approx_depth=approx_depth,
                                 pair_props=pair_props)
    scamp5Program = csim_to_scamp5(csimProgram)

    # Output to files
    with open(filename_prefix + str(k + 1) + '.txt', 'w') as f:
        for l in scamp5Program:
            f.write(l + '\n')

#################################################
# Generate the 3 convolutions with incrementally less registers
#################################################
# Generate CSIM code, with all registers available
start_register = ['A', 'B', 'C']
available_registers = [['B', 'C', 'D', 'E'], ['C', 'D', 'E'], ['D', 'E']]
filename_prefix = '_out_conv_bis_'

for k in range(3):
Esempio n. 2
0
available_registers = [['B', 'C', 'D', 'E'], ['C', 'D', 'E'], ['C', 'D', 'E'],
                       ['C', 'D', 'E']]
filename_prefix = '_out_conv1_'

for k in range(4):
    csimProgram, _, _ = generate(w1_val[:, :, 0, k],
                                 search_time,
                                 start_reg=start_register[k],
                                 target_reg=start_register[k],
                                 available_regs=[start_register[k]] +
                                 available_registers[k],
                                 verbose=0,
                                 out_format='CSIM',
                                 approx_depth=approx_depth,
                                 pair_props=pair_props)
    scamp5Program = csim_to_scamp5(csimProgram)

    # Output to files
    with open(filename_prefix + str(k + 1) + '.txt', 'w') as f:
        for l in scamp5Program:
            f.write(l + '\n')


#################################################
# Generate the remaining 4*8 convolutions (second layer)
# conv_2_1 to conv_2_8 are computed in AREG C.
#################################################
def sparsify_kernel(original_kernel):
    out = np.zeros((5, 5))
    out[::2, ::2] = original_kernel
    return out