def one_layer(image_size, filter_size, in_chn, out_chn, block_size, ifmap, weights, bias, num_nonzero, pruner_name="NaivePruner"): os_tb = OSArchTB(image_size, filter_size, in_chn, out_chn, block_size, ifmap, weights, bias, pruner_name, num_nonzero) run_tb(os_tb, verbose=False) return os_tb.stimulus.ofmap
def main(architecture_name, layer_name, mapping_name, bias_data_name, weights_data_name, ifmap_data_name, stats_name): from nnsim.simulator import run_tb # ======================================================================= print('\t SETTING UP WS DESIGN TESTBENCH...') print('##############################################') print(' architecture:', architecture_name, \ '\n layer:', layer_name, \ '\n mapping: ', mapping_name,\ '\n bias_data:', bias_data_name,\ '\n ifmap_data:', ifmap_data_name,\ '\n weights_data:', weights_data_name,\ '\n stats_name:', stats_name) print('##############################################') #============================================================== # Instantiate & Configure Testbench #============================================================== setup = {'architecture_name': architecture_name, \ 'layer_name': layer_name,\ 'bias_data_name': bias_data_name,\ 'ifmap_data_name': ifmap_data_name,\ 'weights_data_name': weights_data_name,\ 'mapping_name': mapping_name} tb = ws_PE_sparse_tb(setup) tb.configure() # ============================================================== # run simulation #============================================================== # directory for saving the stats (access counts, traces, etc.) import os os.makedirs(stats_name, exist_ok=True) # start simulation run_tb(tb, \ verbose = False, \ dump_stats = True, \ stats_dir = stats_name, \ nticks = None)
out_chn=6, name='conv1', activations=(ReLU('name=relu1'),Pool(dh=2,dw=2,name='pool')) ), Conv(image_size=(4, 4), filter_size=(3, 3), in_chn=6, out_chn=2, name='conv2', activations=(ReLU('name=relu2'),) ), FC(input_size=32, output_size=11, name='fc1', activations=(ReLU('name=relu3'),) ), FC(input_size=11, output_size=3, name='fc2', activations=(ReLU('name=relu4'),) ), ] tb = MetaArchTB(arr_x=8, arr_y=4, chn_per_word=4, layers=layers, batch_size=2 ) run_tb(tb, verbose=False, dump_stats=True)
for tup in noc_multicast_list: sub_module, key = tup[0], tup[1] noc_multicasts += sub_module.raw_stats[key] self.raw_stats['total_noc_multicasts'] = noc_multicasts ### scale memory access stats by energy factors to determine the energy stats self.raw_stats['dram_energy'] = self.raw_stats[ 'dram_mem_acc'] * DRAM_ENERGY_FACTOR self.raw_stats[ 'glb_energy'] = self.raw_stats['glb_mem_acc'] * GLB_ENERGY_FACTOR self.raw_stats[ 'rf_energy'] = self.raw_stats['rf_mem_acc'] * RF_ENERGY_FACTOR self.raw_stats['data_energy'] = self.raw_stats['dram_energy'] + \ self.raw_stats['glb_energy'] + self.raw_stats['rf_energy'] self.raw_stats['comp_energy'] = self.raw_stats[ 'pe_comp_energy'] + self.raw_stats['tr_alu_comp_energy'] ### total energy = data energy + comp energy self.raw_stats['total_energy'] = self.raw_stats[ 'data_energy'] + self.raw_stats['comp_energy'] if __name__ == "__main__": from nnsim.simulator import run_tb ws_tb = WSArchTB() run_tb(ws_tb, verbose=False)
def test_fifo_unchecked(): with pytest.raises(FIFOError): fifo_tb = FIFOTB(False) sim.run_tb(fifo_tb, 20, True)
def test_fifo_checked(): fifo_tb = FIFOTB(True) sim.run_tb(fifo_tb, 20, True)
# send in one extra iteration to flush out last outputs print("Stimulus:") print("[") for i in range(len(self.test_data)-1): print(self.test_data[i]) print("]") def tick(self): if (self.in_chn.vacancy() and not self.iteration == self.iterations+1): imin = self.curr_set*self.input_size imax = imin+self.input_size data = [self.test_data[self.iteration][i] for i in range(imin, imax)] self.in_chn.push(data) self.curr_set += 1 if (self.curr_set == self.in_sets): self.curr_set = 0 self.iteration += 1 if (self.out_chn.valid()): data = self.out_chn.pop() print(data) #print("out_counter: ", self.out_counter) self.out_counter += 1 if (self.out_counter == self.iterations): raise Finish("Check manually") if __name__ == "__main__": from nnsim.simulator import run_tb converter_tb = ConverterTB() run_tb(converter_tb, verbose=False)
def test_channel(): channel_tb = ChannelTB() sim.run_tb(channel_tb, 100, True)
def test_reg_rd_wr(): reg_tb = RegTB() sim.run_tb(reg_tb, 10, True)