Skip to content

Commit

Permalink
transformer: add start of log reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
Viviane Potocnik committed Oct 20, 2023
1 parent 22421ab commit 1d6a06c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions sw/apps/transformer/src/transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -925,21 +925,30 @@ static inline void transformer_layer_fp64(transformer_layer_fp64_t *const l) {

snrt_cluster_hw_barrier();

for (int i = 0; i < B_r_lin2 / num_cores; i++) {
for (int j = 0; j < B_c_lin2; j++) {
dump_idx(i * B_c_lin2 + j + ofmap_offset);
dump_debug(ofmap_lin2[i * B_c_lin2 + j + ofmap_offset]);
}
}
// for (int i = 0; i < B_r_lin2 / num_cores; i++) {
// for (int j = 0; j < B_c_lin2; j++) {
// dump_idx(i * B_c_lin2 + j + ofmap_offset);
// dump_debug(ofmap_lin2[i * B_c_lin2 + j + ofmap_offset]);
// }
// }
} else {
snrt_cluster_hw_barrier();
}
}
uint32_t end_loop_inner = snrt_mcycle();
}
uint32_t end_loop_outer = snrt_mcycle();

snrt_cluster_hw_barrier();

// now we will add the partial results together
// in a logarithmic reduction fashion

float reduction_depth = log2(num_heads);
dump_debug(reduction_depth);
// round to the next integer (ceiling)
uint32_t reduction_depth_int = (uint32_t)ceil(reduction_depth);
dump_id(reduction_depth_int);

}


Expand Down

0 comments on commit 1d6a06c

Please sign in to comment.