@@ -492,23 +492,24 @@ def create_net(self) -> str: # pylint: disable=too-many-locals,too-many-branche
492
492
493
493
if in_sequences [ll ] is not None :
494
494
if operands [ll ] == 1 : # cat
495
- min_proc = - 1
496
- max_proc = - 1
497
- for _ , lt in enumerate (in_sequences [ll ]):
498
- first_proc = ffs (output_processor_map [lt ])
499
- last_proc = fls (output_processor_map [lt ])
500
- if first_proc <= min_proc :
501
- eprint (f'Layer { ll } : In `in_sequences` { in_sequences [ll ]} , '
502
- 'an earlier layer in the sequence uses a higher first '
503
- f'processor ({ min_proc } ) than layer { lt } which uses '
504
- f'processor { first_proc } .' )
505
- if last_proc <= max_proc :
506
- eprint (f'Layer { ll } : In `in_sequences` { in_sequences [ll ]} , '
507
- 'an earlier layer in the sequence uses a higher last '
508
- f'processor ({ max_proc } ) than layer { lt } which uses '
509
- f'processor { last_proc } .' )
510
- min_proc = first_proc
511
- max_proc = last_proc
495
+ if write_gap [ll ] == 0 :
496
+ min_proc = - 1
497
+ max_proc = - 1
498
+ for _ , lt in enumerate (in_sequences [ll ]):
499
+ first_proc = ffs (output_processor_map [lt ])
500
+ last_proc = fls (output_processor_map [lt ])
501
+ if first_proc <= min_proc :
502
+ eprint (f'Layer { ll } : In `in_sequences` { in_sequences [ll ]} , '
503
+ 'an earlier layer in the sequence uses a higher first '
504
+ f'processor ({ min_proc } ) than layer { lt } which uses '
505
+ f'processor { first_proc } .' )
506
+ if last_proc <= max_proc :
507
+ eprint (f'Layer { ll } : In `in_sequences` { in_sequences [ll ]} , '
508
+ 'an earlier layer in the sequence uses a higher last '
509
+ f'processor ({ max_proc } ) than layer { lt } which uses '
510
+ f'processor { last_proc } .' )
511
+ min_proc = first_proc
512
+ max_proc = last_proc
512
513
else : # eltwise
513
514
eltwise_proc_map = 0
514
515
for _ , lt in enumerate (in_sequences [ll ]):
@@ -569,7 +570,7 @@ def create_net(self) -> str: # pylint: disable=too-many-locals,too-many-branche
569
570
if not block_mode and (embedded_code or compact_data ):
570
571
sampledata_header = \
571
572
open (os .path .join (base_directory , test_name , state .sample_filename ), mode = 'w' )
572
- if state .generate_kat and state .result_filename .lower () != 'none' :
573
+ if embedded_code and state .generate_kat and state .result_filename .lower () != 'none' :
573
574
sampleoutput_header = \
574
575
open (os .path .join (base_directory , test_name , state .result_filename ), mode = 'w' )
575
576
else :
@@ -1211,43 +1212,47 @@ def create_net(self) -> str: # pylint: disable=too-many-locals,too-many-branche
1211
1212
for _ , group in enumerate (groups_used ):
1212
1213
apb .output (f' // Layer { r * layers + ll } group { group } \n ' , embedded_code )
1213
1214
1214
- if hasattr (tc .dev , 'LREG_NXTLYR' ):
1215
- val = 0
1216
- if link_layer :
1217
- if ll != final_layer :
1218
- val = 1 << 7 | (ll + 1 )
1219
- else :
1220
- val = 1 << 8 # Stop
1215
+ val = 0
1216
+ if link_layer :
1217
+ if ll != final_layer :
1218
+ val = 1 << 7 | (ll + 1 )
1221
1219
else :
1222
- lt = next_sequence [ll ]
1223
- if lt == - 1 :
1224
- if ll != layers - 1 : # Don't set stop bit unless required
1225
- val = 1 << 8
1226
- elif lt != ll + 1 :
1227
- val = 1 << 7 | lt
1228
- elif snoop_sequence [ll ] is not None :
1229
- lt = snoop_sequence [ll ]
1230
- assert lt >= 0
1231
- val = 1 << 7 | lt
1232
- if lt != - 1 :
1233
- if in_sequences [lt ] is not None and ll in in_sequences [lt ] \
1234
- and operands [lt ] == 1 :
1235
- if in_offset [lt ] != out_offset [ll ]:
1236
- wprint (f'Layer { ll } : The input offset of the next '
1237
- f'sequence (layer { lt } , 0x{ in_offset [lt ]:04x} ) '
1238
- "does not match the current layer's output "
1239
- f'offset (0x{ out_offset [ll ]:04x} ).' )
1240
- if input_chan [lt ] != output_chan [ll ] \
1241
- * len (in_sequences [lt ]) \
1242
- or input_dim [lt ] != output_dim [ll ]:
1243
- wprint (f'Layer { ll } : The input dimensions of the next '
1244
- f'sequence (layer { lt } , '
1245
- f'{ len (in_sequences [lt ])} inputs, '
1246
- f'{ input_chan [lt ]} x{ input_dim_str [lt ]} ) do '
1247
- "not match the current layer's output "
1248
- "dimensions "
1249
- f'({ output_chan [ll ]} x{ output_dim_str [ll ]} ).' )
1220
+ val = 1 << 8 # Stop
1221
+ else :
1222
+ lt = next_sequence [ll ]
1223
+ if lt == - 1 :
1224
+ if ll != layers - 1 : # Don't set stop bit unless required
1225
+ val = 1 << 8
1226
+ elif lt != ll + 1 :
1227
+ val = 1 << 7 | lt
1228
+ elif snoop_sequence [ll ] is not None :
1229
+ lt = snoop_sequence [ll ]
1230
+ assert lt >= 0
1231
+ val = 1 << 7 | lt
1232
+ if lt != - 1 :
1233
+ if in_sequences [lt ] is not None and ll in in_sequences [lt ] \
1234
+ and operands [lt ] == 1 :
1235
+ ll_index = in_sequences [lt ].index (ll )
1236
+ ll_offset = out_offset [ll ] - ll_index * write_gap [ll ] * 4
1237
+ if in_offset [lt ] != ll_offset :
1238
+ wprint (f'Layer { ll } : The input offset of the next '
1239
+ f'sequence (layer { lt } , 0x{ in_offset [lt ]:04x} ) '
1240
+ "does not match the current layer's output "
1241
+ f'(offset 0x{ out_offset [ll ]:04x} - write gap '
1242
+ f'{ write_gap [ll ]} * sequence position '
1243
+ f'{ ll_index } * 4 = 0x{ ll_offset :04x} ).' )
1244
+ if input_chan [lt ] != output_chan [ll ] \
1245
+ * len (in_sequences [lt ]) \
1246
+ or input_dim [lt ] != output_dim [ll ]:
1247
+ wprint (f'Layer { ll } : The input dimensions of the next '
1248
+ f'sequence (layer { lt } , '
1249
+ f'{ len (in_sequences [lt ])} inputs, '
1250
+ f'{ input_chan [lt ]} x{ input_dim_str [lt ]} ) do '
1251
+ "not match the current layer's output "
1252
+ "dimensions "
1253
+ f'({ output_chan [ll ]} x{ output_dim_str [ll ]} ).' )
1250
1254
1255
+ if hasattr (tc .dev , 'LREG_NXTLYR' ):
1251
1256
apb .write_lreg (group , r * layers + ll , tc .dev .LREG_NXTLYR , val ,
1252
1257
comment = ' // Next Layer' )
1253
1258
@@ -2751,6 +2756,7 @@ def run_eltwise(
2751
2756
test_name ,
2752
2757
timeout ,
2753
2758
riscv = riscv ,
2759
+ groups_used = groups_used ,
2754
2760
)
2755
2761
assets .copy ('assets' , 'rtlsim-ai' + str (device ), base_directory , test_name )
2756
2762
if riscv_cache :
0 commit comments