| Files | Last commit | Last update |
|---|---|---|
| 22 days ago | ||
| 19 days ago | ||
| 10 months ago | ||
| 5 days ago | ||
| 5 days ago | ||
| 27 days ago | ||
| 21 days ago | ||
| 14 days ago | ||
| 15 days ago |
Segsum
English | 简体中文
Product Support Status
| Product | Supported |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 products | √ |
| Atlas A2 products | √ |
| Atlas 200I/500 A2 inference products | × |
| Atlas inference products | × |
| Atlas training products | × |
| Kirin X90 processor series products | √ |
| Kirin 9030 processor series products | √ |
Function Description
-
Operator function: performs the segment sum computation. It generates a semi-separable matrix with the diagonal of 1 and the upper triangle of 0.
-
Computation formula (taking 4D input as an example):
-
The input self is expanded from (N1,N2,N3,N4) to (N1,N2,N3,N4,1).
-
Broadcasting is performed to obtain (N1,N2,N3,N4,N4).
-
A (N4,N4) triangular matrix A of the bool type is generated, where the upper triangle is True, the lower triangle is False, and the diagonal is True.
-
The elements in the input self corresponding to the positions whose values are True in matrix A are filled with 0.
selfi={selfi,Ai==False0,Ai==Trueself_i= \begin{cases}self_i,\quad A_i==False \\0, \quad A_i==True \end{cases}
-
The cumsum accumulation is performed along the second-to-last dimension of self. For an element from the dimension perspective (the indexes of other dimensions remain unchanged, and the index of the current dimension increases sequentially), selfTemp_iselfTemp\_{i} is the element at the corresponding position in the output tensor.
selfTempi=self1+self2+self3+......+selfiselfTemp_{i} = self_{1} + self_{2} + self_{3} + ...... + self_{i}
-
A (N4,N4) triangular matrix B of the bool type is generated, where the upper triangle is True, the lower triangle is False, and the diagonal is False.
-
The elements in selfTemp corresponding to the positions whose values are True in matrix B are filled with -inf.
outi={selfTempi,Bi==False−inf,Bi==Trueout_i= \begin{cases}selfTemp_i,\quad B_i==False \\-inf, \quad B_i==True \end{cases}
-
The exponential of each element in selfTemp is computed.
outi=eselfTempiout_i=e^{selfTemp_i}
-
Parameter Description
| Parameter Name | Input/Output/Attribute | Description | Data Type | Data Format |
|---|---|---|---|---|
| x | Input | Input for the segment sum computation, corresponding to `self` in the formula. | FLOAT32, FLOAT16, BFLOAT16 | ND |
| y | Output | Output after the segment sum computation, corresponding to `out` in the formula. The number of output dimensions must be 1 greater than the number of input dimensions, and 4D or 5D is supported. When the input `x` is 3D, the dimension sizes of the first 3 dimensions of the output are the same as those of `x`, and the dimension size of the last dimension is the same as that of the 3rd dimension. When the input `x` is 4D, the dimension sizes of the first 4 dimensions of the output are the same as those of `x`, and the dimension size of the last dimension is the same as that of the 4th dimension. The data type is the same as the data type of the input `x`. | FLOAT32, FLOAT16, BFLOAT16 | ND |
- Kirin X90/Kirin 9030 processor series products: BFLOAT16 is not supported.
Constraint Description
None
Invocation Description
| Invocation Method | Sample Code | Description |
|---|---|---|
| aclnn API | test_aclnn_exp_segsum | Invokes the Segsum operator through the aclnnExpSegsum API. |