Skip to content

Commit

Permalink
Fix a out-of-bounds accessing bug.
Browse files Browse the repository at this point in the history
Before applying this modification, when executing the benchmark listed below, a segment fault will be reported because of the out-of-bounds accessing to the packed_weights buffer:

./x16-packw-bench --benchmark_filter=qs8_qc4w_packw_x8c8__reference/sd1x_diffusion/B:8/M:4096/N:4096/K:40/real_time --benchmark_min_time=0.1

Here, the packed_weights buffer is resized to a reasonable size and the error will not be reported.
  • Loading branch information
txwhqq committed Jan 3, 2025
1 parent c2bddb4 commit 56db0a1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bench/packw-benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static void qs8_qc4w_packw(benchmark::State& state,
const size_t dim_k = state.range(3); // dim_k is kc parameter

const size_t rounded_n = benchmark::utils::RoundUp(dim_n, nr);
const size_t rounded_k = benchmark::utils::RoundUp(dim_k, kr * sr);
const size_t rounded_k = round_up_po2(dim_k, 2 * kr * sr);
const size_t rounded_size = rounded_n * rounded_k / 2 + rounded_n * sizeof(uint32_t);

std::random_device random_device;
Expand Down

0 comments on commit 56db0a1

Please sign in to comment.