From 87f94cade913e7667017463959e359bd9bcf9938 Mon Sep 17 00:00:00 2001 From: luyuhong Date: Wed, 4 Jun 2025 10:48:50 +0800 Subject: [PATCH] [CANN]:Replace aclrtMemsetSync with aclnnInplaceZero operator to create zero tensors more efficiently and consistently within the computation graph --- ggml/src/ggml-cann/aclnn_ops.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ggml/src/ggml-cann/aclnn_ops.cpp b/ggml/src/ggml-cann/aclnn_ops.cpp index 69483de8f363e..4d5c2c182521f 100755 --- a/ggml/src/ggml-cann/aclnn_ops.cpp +++ b/ggml/src/ggml-cann/aclnn_ops.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -804,10 +805,11 @@ static aclTensor* aclnn_zero(ggml_backend_cann_context& ctx, void* buffer, nb[i] = nb[i - 1] * ne[i - 1]; } - ggml_cann_async_memset(ctx, buffer, n_bytes, 0); aclTensor* zero = ggml_cann_create_tensor(buffer, type, type_size, ne, nb, dims); + GGML_CANN_CALL_ACLNN_OP(ctx, InplaceZero, zero); return zero; + GGML_UNUSED(n_bytes); } /**