From 56db0a1a8320d82c387c5d5e3355811a7388de13 Mon Sep 17 00:00:00 2001 From: Calvin Qiu <1753615516@qq.com> Date: Fri, 3 Jan 2025 18:11:07 +0800 Subject: [PATCH] Fix a out-of-bounds accessing bug. 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. --- bench/packw-benchmark.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/packw-benchmark.h b/bench/packw-benchmark.h index fe11340878a..7d550c5fa43 100644 --- a/bench/packw-benchmark.h +++ b/bench/packw-benchmark.h @@ -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;