@@ -109,8 +109,11 @@ void ggml_cann_repeat(ggml_backend_cann_context& ctx, ggml_tensor* dst) {
109
109
* @brief Adds two tensors element-wise and stores the result in a destination
110
110
* tensor.
111
111
*
112
- * This function performs the operation: dst = acl_src0 + alpha * acl_src1
113
- * where alpha is a scalar value.
112
+ * This function performs the operation:
113
+ * \f[
114
+ * dst = acl\_src0 + alpha \times acl\_src1
115
+ * \f]
116
+ * where alpha is a scalar value and defaults to 1.0f.
114
117
*
115
118
* @param ctx The context for the CANN backend operations.
116
119
* @param acl_src0 The first source tensor.
@@ -119,7 +122,6 @@ void ggml_cann_repeat(ggml_backend_cann_context& ctx, ggml_tensor* dst) {
119
122
*/
120
123
static void aclnn_add (ggml_backend_cann_context& ctx, aclTensor* acl_src0,
121
124
aclTensor* acl_src1, aclTensor* acl_dst) {
122
- // add: dst = acl_src0 + alpha*acl_src1
123
125
aclScalar* alpha = nullptr ;
124
126
float alphaValue = 1 .0f ;
125
127
alpha = aclCreateScalar (&alphaValue, aclDataType::ACL_FLOAT);
@@ -248,8 +250,11 @@ void ggml_cann_concat(ggml_backend_cann_context& ctx, ggml_tensor* dst) {
248
250
* @brief Creates a tensor with values starting from `start`, incremented by
249
251
* `step`, and ending before `stop`.
250
252
*
251
- * This function performs the operation: [start, stop), out(i+1) = out(i) +
252
- * step.
253
+ * This function performs the operation:
254
+ * \f[
255
+ * \text {out}_{i+1}=\text {out}_i+\text {step}
256
+ * \f]
257
+ * the range is [start, stop).
253
258
*
254
259
* @param ctx The context for the CANN backend operations.
255
260
* @param acl_dst The destination tensor where the values will be stored.
@@ -893,7 +898,7 @@ void ggml_cann_dup(ggml_backend_cann_context& ctx, ggml_tensor* dst) {
893
898
ACL_CHECK (aclDestroyTensor (acl_dst));
894
899
return ;
895
900
}
896
- // TODO: simplefify
901
+ // TODO: simplify
897
902
if (src->type == GGML_TYPE_F16) {
898
903
if (dst->type == GGML_TYPE_Q8_0) {
899
904
aclrtlaunch_ascendc_quantize_f16_q8_0 (
@@ -1396,6 +1401,10 @@ void ggml_cann_im2col(ggml_backend_cann_context& ctx, ggml_tensor* dst) {
1396
1401
*
1397
1402
* This function computes the exponential of each element in the source tensor
1398
1403
* `acl_src` and stores the result back into the same tensor.
1404
+ * The operation is defined as:
1405
+ * \f[
1406
+ * \text {acl_src}_i=e^{acl\_src_i}
1407
+ * \f]
1399
1408
*
1400
1409
* @param ctx The context for the CANN backend operations.
1401
1410
* @param acl_src The tensor on which the exponential function will be applied.
@@ -1422,7 +1431,12 @@ static void aclnn_exp(ggml_backend_cann_context& ctx, aclTensor* acl_src) {
1422
1431
*
1423
1432
* This function multiplies each element of the source tensor `acl_src` by the
1424
1433
* scalar `scale` and stores the result in the destination tensor `acl_dst`. If
1425
- * `inplace` is true, the operation is performed in-place on `acl_src`.
1434
+ * `inplace` is true, `acl_dst` will not be used and the operation is performed
1435
+ * in-place on `acl_src`.
1436
+ * The operation is defined as:
1437
+ * \f[
1438
+ * \text {acl_dst}_i=\text {acl_src}_i \times \text {scale}
1439
+ * \f]
1426
1440
*
1427
1441
* @param ctx The context for the CANN backend operations.
1428
1442
* @param acl_src The source tensor whose elements will be multiplied.
@@ -1471,6 +1485,10 @@ static void aclnn_muls(ggml_backend_cann_context& ctx, aclTensor* acl_src,
1471
1485
*
1472
1486
* This function performs an element-wise multiplication of the tensors
1473
1487
* `acl_src` and `acl_other` and stores the result in `acl_src`.
1488
+ * The operation is defined as:
1489
+ * \f[
1490
+ * \text {acl_src}_i=\text {acl_src}_i \times \text {acl_other}_i
1491
+ * \f]
1474
1492
*
1475
1493
* @param ctx The context for the CANN backend operations.
1476
1494
* @param acl_src The source tensor where the multiplication result will be
@@ -1500,6 +1518,10 @@ static void aclnn_inplace_mul(ggml_backend_cann_context& ctx,
1500
1518
*
1501
1519
* This function performs element-wise multiplication of the tensors `acl_src`
1502
1520
* and `acl_other` and stores the result in the destination tensor `acl_dst`.
1521
+ * The operation is defined as:
1522
+ * \f[
1523
+ * \text {acl_dst}_i=\text {acl_src}_i \times \text {acl_other}_i
1524
+ * \f]
1503
1525
*
1504
1526
* @param ctx The context for the CANN backend operations.
1505
1527
* @param acl_src The first tensor for element-wise multiplication.
@@ -1528,6 +1550,10 @@ static void aclnn_mul(ggml_backend_cann_context& ctx,
1528
1550
*
1529
1551
* This function computes the cosine of each element in the source tensor `acl_src`
1530
1552
* and stores the result in the destination tensor `acl_dst`.
1553
+ * The operation is defined as:
1554
+ * \f[
1555
+ * \text {acl_dst}_i=\cos \left(\text {acl_src}_i\right)
1556
+ * \f]
1531
1557
*
1532
1558
* @param ctx The context for the CANN backend operations.
1533
1559
* @param acl_src The source tensor on which the cosine function will be applied.
@@ -1554,7 +1580,11 @@ static void aclnn_cos(ggml_backend_cann_context& ctx, aclTensor* acl_src,
1554
1580
*
1555
1581
* This function computes the sine of each element in the source tensor `acl_src`
1556
1582
* and stores the result in the destination tensor `acl_dst`.
1557
- *
1583
+ * The operation is defined as:
1584
+ * \f[
1585
+ * \text {acl_dst}_i=\sin \left(\text {acl_src}_i\right)
1586
+ * \f]
1587
+
1558
1588
* @param ctx The context for the CANN backend operations.
1559
1589
* @param acl_src The source tensor on which the sine function will be applied.
1560
1590
* @param acl_dst The destination tensor where the sine results will be stored.
@@ -1721,6 +1751,10 @@ static void aclnn_fill_scalar(ggml_backend_cann_context& ctx, float scalar,
1721
1751
*
1722
1752
* This function computes the element-wise power of the destination tensor
1723
1753
* `acl_dst` raised to the power of the exponent tensor `acl_exp`.
1754
+ * The operation is defined as:
1755
+ * \f[
1756
+ * \text {acl_dst}_i=acl\_dst_i^{\text {acl_exp}_i}
1757
+ * \f]
1724
1758
*
1725
1759
* @param ctx The context for the CANN backend operations.
1726
1760
* @param acl_dst The destination tensor, which also serves as the base tensor.
@@ -1764,12 +1798,16 @@ static void aclnn_pow_tensor_tensor(ggml_backend_cann_context& ctx,
1764
1798
* @param dst The destination tensor object for additional metadata.
1765
1799
*
1766
1800
* The function performs the following steps:
1767
- * 1. Calculates the logarithm floor of the number of heads to determine the base for bias calculation.
1768
- * 2. Initializes arrays with arithmetic sequences and fills them with bias values.
1769
- * 3. Computes the bias tensor based on the calculated biases and arithmetic sequences.
1801
+ * 1. Calculates the logarithm floor of the number of heads to determine the
1802
+ base for bias calculation.
1803
+ * 2. Initializes arrays with arithmetic sequences and fills them with bias
1804
+ values.
1805
+ * 3. Computes the bias tensor based on the calculated biases and arithmetic
1806
+ sequences.
1770
1807
* 4. Reshapes the bias tensor to match the dimensions of the input tensors.
1771
1808
* 5. Multiplies the position tensor by the bias tensor.
1772
- * 6. Adds the result of the multiplication to the source tensor to produce the final output.
1809
+ * 6. Adds the result of the multiplication to the source tensor to produce the
1810
+ final output.
1773
1811
*/
1774
1812
static void aclnn_alibi (ggml_backend_cann_context& ctx, aclTensor* acl_src,
1775
1813
aclTensor* acl_position, aclTensor* acl_dst,
@@ -2189,6 +2227,10 @@ static void aclnn_repeat_interleave(ggml_backend_cann_context& ctx,
2189
2227
* This function computes the matrix multiplication of the input tensor
2190
2228
* `acl_input` and the weight tensor `acl_weight`, and stores the result in the
2191
2229
* destination tensor `acl_dst`.
2230
+ * The operation is defined as:
2231
+ * \f[
2232
+ * \text {acl_dst}=\text {acl_input@acl_weight}
2233
+ * \f]
2192
2234
*
2193
2235
* @param ctx The context for the CANN backend operations.
2194
2236
* @param acl_input The input tensor for the matrix multiplication.
0 commit comments