@@ -1349,7 +1349,7 @@ static void aclnn_pow_tensor_tensor(ggml_backend_cann_context& ctx,
13491349 * @param stop Stopping exponent offset (exclusive).
13501350 * @param step Step size for the exponent increment.
13511351 */
1352- static void aclnn_get_slope_inner (ggml_backend_cann_context& ctx, void * slope_buffer,
1352+ static void aclnn_get_slope_inner (ggml_backend_cann_context& ctx, void * slope_buffer,
13531353 float m, int64_t size, float start, float stop, float step){
13541354 int64_t ne[] = {size};
13551355 size_t nb[] = {sizeof (float )};
@@ -1395,17 +1395,17 @@ static void aclnn_get_slope_inner(ggml_backend_cann_context& ctx, void* slope_bu
13951395 * @param max_bias Maximum bias value for slope computation.
13961396 *
13971397*/
1398- static void aclnn_get_slope (ggml_backend_cann_context & ctx, int64_t n_head,
1398+ static void aclnn_get_slope (ggml_backend_cann_context & ctx, int64_t n_head,
13991399 void * slope_buffer, float max_bias) {
14001400 const int n_head_log2 = 1u << (uint32_t ) floor (log2 (n_head));
14011401
14021402 float m0 = powf (2 .0f , -(max_bias) / n_head_log2);
14031403 float m1 = powf (2 .0f , -(max_bias / 2 .0f ) / n_head_log2);
14041404
1405- // const float slope = (max_bias > 0.0f) ?
1406- // h < n_head_log2 ?
1407- // powf(m0, h + 1) :
1408- // powf(m1, 2*(h - n_head_log2) + 1) :
1405+ // const float slope = (max_bias > 0.0f) ?
1406+ // h < n_head_log2 ?
1407+ // powf(m0, h + 1) :
1408+ // powf(m1, 2*(h - n_head_log2) + 1) :
14091409 // 1.0f;
14101410 // arange1
14111411 float start = 0 + 1 ;
@@ -1421,7 +1421,7 @@ static void aclnn_get_slope(ggml_backend_cann_context & ctx, int64_t n_head,
14211421 step = 2 ;
14221422 count = n_head - n_head_log2;
14231423 aclnn_get_slope_inner (
1424- ctx, (char *) slope_buffer + n_head_log2 * sizeof (float ),
1424+ ctx, (char *) slope_buffer + n_head_log2 * sizeof (float ),
14251425 m1, count, start, end + 1 , step);
14261426 }
14271427}
@@ -1447,7 +1447,7 @@ static void aclnn_get_slope(ggml_backend_cann_context & ctx, int64_t n_head,
14471447 * - Write data into dst_ptr using only the shape information of the dst tensor.
14481448 * - `GGML_MAX_DIMS + 2` is used to extend tensor dimensions for broadcasting.
14491449 */
1450- static void aclnn_add_alibi (ggml_backend_cann_context& ctx, ggml_tensor* mask,
1450+ static void aclnn_add_alibi (ggml_backend_cann_context& ctx, ggml_tensor* mask,
14511451 ggml_tensor* dst, void * dst_ptr, float max_bias) {
14521452 void * slope_buffer = nullptr ;
14531453 void * bias_buffer = nullptr ;
@@ -1468,15 +1468,15 @@ static void aclnn_add_alibi(ggml_backend_cann_context& ctx, ggml_tensor* mask,
14681468
14691469 // broadcast the mask across rows
14701470 int64_t mask_ne[] = { mask->ne [0 ], dst->ne [1 ], mask->ne [2 ], 1 , mask->ne [3 ], 1 };
1471- size_t mask_nb[] = {
1471+ size_t mask_nb[] = {
14721472 mask_nb[0 ] = mask->nb [0 ], mask_nb[1 ] = mask->nb [1 ], mask_nb[2 ] = mask->nb [2 ],
1473- mask_nb[3 ] = mask->nb [2 ], mask_nb[4 ] = mask->nb [3 ], mask_nb[5 ] = mask->nb [3 ]
1473+ mask_nb[3 ] = mask->nb [2 ], mask_nb[4 ] = mask->nb [3 ], mask_nb[5 ] = mask->nb [3 ]
14741474 };
14751475
14761476 int64_t dst_ne[] = { dst->ne [0 ], dst->ne [1 ], mask->ne [2 ], nr2, mask->ne [3 ], nr3 };
1477- size_t dst_nb[] = {
1477+ size_t dst_nb[] = {
14781478 dst_nb[0 ] = dst->nb [0 ], dst_nb[1 ] = dst->nb [1 ], dst_nb[2 ] = dst->nb [2 ],
1479- dst_nb[3 ] = dst->nb [2 ], dst_nb[4 ] = dst->nb [3 ], dst_nb[5 ] = dst->nb [3 ]
1479+ dst_nb[3 ] = dst->nb [2 ], dst_nb[4 ] = dst->nb [3 ], dst_nb[5 ] = dst->nb [3 ]
14801480 };
14811481
14821482 // slope is a 1 dim tensor, slope.ne2 == dst.ne2
@@ -1488,15 +1488,15 @@ static void aclnn_add_alibi(ggml_backend_cann_context& ctx, ggml_tensor* mask,
14881488 }
14891489
14901490 aclTensor* acl_slope = ggml_cann_create_tensor (
1491- slope_buffer, ACL_FLOAT, sizeof (float ),
1491+ slope_buffer, ACL_FLOAT, sizeof (float ),
14921492 slope_ne, slope_nb, GGML_MAX_DIMS + 2 );
14931493 aclTensor* acl_mask = ggml_cann_create_tensor (
14941494 mask, mask_ne, mask_nb, GGML_MAX_DIMS + 2 );
1495-
1495+
14961496 // write data into dst_ptr using only the shape information of the dst tensor.
14971497 aclTensor* acl_dst = ggml_cann_create_tensor (
1498- dst_ptr, ggml_cann_type_mapping (dst->type ),
1499- ggml_type_size (dst->type ), dst_ne, dst_nb,
1498+ dst_ptr, ggml_cann_type_mapping (dst->type ),
1499+ ggml_type_size (dst->type ), dst_ne, dst_nb,
15001500 GGML_MAX_DIMS + 2 );
15011501
15021502 if (max_bias > 0 .0f ) {
@@ -1507,7 +1507,7 @@ static void aclnn_add_alibi(ggml_backend_cann_context& ctx, ggml_tensor* mask,
15071507 bias_nb[i] = bias_nb[i - 1 ] * bias_ne[i - 1 ];
15081508 }
15091509 aclTensor* bias_tensor = ggml_cann_create_tensor (
1510- bias_buffer, ACL_FLOAT, sizeof (float ),
1510+ bias_buffer, ACL_FLOAT, sizeof (float ),
15111511 bias_ne, bias_nb, GGML_MAX_DIMS + 2 );
15121512
15131513 aclnn_mul (ctx, acl_slope, acl_mask, bias_tensor);
@@ -1537,7 +1537,7 @@ void ggml_cann_cpy(ggml_backend_cann_context & ctx, ggml_tensor * dst) {
15371537 * @param acl_dst The destination tensor where the softmax results will be
15381538 * stored.
15391539 */
1540- static void aclnn_softmax (ggml_backend_cann_context & ctx,
1540+ static void aclnn_softmax (ggml_backend_cann_context & ctx,
15411541 aclTensor* acl_src, int64_t dim, aclTensor * acl_dst) {
15421542 GGML_CANN_CALL_ACLNN_OP (ctx, Softmax, acl_src, dim, acl_dst);
15431543}
0 commit comments