CANN: fix acl_rstd allocation size in ggml_cann_rms_norm (#15760)

Fixes #15330

Adjust the allocation size of acl_rstd. The parameter `dims` is set to 3 according to the CANN documentation.

Co-authored-by: Yuchuan <yuchuan-cao@users.noreply.github.com>
This commit is contained in:
Chenguang Li
2025-09-04 11:03:02 +08:00
committed by GitHub
parent dff7551bfd
commit 239b60e898

View File

@@ -975,18 +975,19 @@ void ggml_cann_rms_norm(ggml_backend_cann_context& ctx, ggml_tensor* dst) {
); );
// build rstd, zero... // build rstd, zero...
size_t acl_rstd_nb[GGML_MAX_DIMS]; int64_t acl_rstd_ne[] = {src->ne[1], src->ne[2], src->ne[3]};
size_t acl_rstd_nb[GGML_MAX_DIMS - 1];
acl_rstd_nb[0] = sizeof(float); acl_rstd_nb[0] = sizeof(float);
for (int i = 1; i < GGML_MAX_DIMS; i++) { for (int i = 1; i < GGML_MAX_DIMS - 1; i++) {
acl_rstd_nb[i] = acl_rstd_nb[i - 1] * src->ne[i - 1]; acl_rstd_nb[i] = acl_rstd_nb[i - 1] * acl_rstd_ne[i - 1];
} }
aclTensor* acl_rstd = get_f32_cache_acl_tensor( aclTensor* acl_rstd = get_f32_cache_acl_tensor(
ctx, ctx,
&ctx.rms_norm_zero_tensor_cache.cache, &ctx.rms_norm_zero_tensor_cache.cache,
ctx.rms_norm_zero_tensor_cache.size, ctx.rms_norm_zero_tensor_cache.size,
src->ne, acl_rstd_ne,
acl_rstd_nb, acl_rstd_nb,
GGML_MAX_DIMS, GGML_MAX_DIMS - 1,
0.0f // value 0.0f // value
); );