For example, the data block stride (address stride between adjacent data blocks in a single repeat) refers to dstBlkStride and srcBlkStride in one-operand APIs, and dstBlkStride, src0BlkStride, and src1BlkStride in two-operand APIs.
You can find the meaning of each parameter in the parameter description of a specific API.
Using high-dimensional tensor sharding compute APIs can make full use of hardware advantages and enable you to flexibly control the repeat execution of instructions and the address stride of operands.
Vector compute is implemented by the Vector Unit. The source and destination operands of vector compute are stored in the UB. In each repeat, the Vector Unit fetches eight data blocks (each data block has consecutive internal addresses, with a length of 32 bytes) from the UB for computation, and writes the computation results into the corresponding eight data blocks. The following figure shows the Exp computation of eight data blocks in a single repeat.




When repeatTime is set to a number greater than 1, multiple repeats are required to complete vector computation. In this case, you can set repeatStride as required.
The following figure shows the scenario where multiple repeats are non-contiguous. In the example, repeatStride is set to 9 for both the source operand and destination operand, indicating that the interval between the start addresses of the same data block between adjacent repeats is nine data blocks. The same data block indicates that the positions of the data block in repeats are the same. For example, src1 and src9 in the following figure are in the adjacent repeats, and they are both the first data block in their repeats. The interval is the value of repeatStride.

The following describes the configurations of dataBlockStride, repeatStride, and mask and provides examples.
dataBlockStride refers to the address stride between adjacent data blocks in the same repeat.

repeatStride refers to the address stride of the same data block between adjacent repeats.




The mask parameter controls the elements that participate in computation in each repeat. You can set this parameter in contiguous mode or bitwise mode.
1 2 3 4 5 6 | // The maximum number of elements that can be processed in a single repeat of the int16_t type is 256/sizeof(int16_t) = 128, mask = 64, and mask ∈ [1, 128]. Therefore, the input is valid. // repeatTime = 1. There are 128 elements in total. A single repeat can process 128 elements. Therefore, repeatTime = 1. // dstBlkStride, src0BlkStride, src1BlkStride = 1. Data is contiguously read and written in a single repeat. // dstRepStride, src0RepStride, src1RepStride = 8. Data is contiguously read and written between repeats. uint64_t mask = 64; AscendC::Add(dstLocal, src0Local, src1Local, mask, 1, { 1, 1, 1, 8, 8, 8 }); |
Result example:
Input (src0Local): [1 2 3... 64... 128] Input (src1Local): [1 2 3... 64... 128] Output (dstLocal): [2 4 6... 128 undefined... undefined]
1 2 3 4 5 6 | // The maximum number of elements that can be processed in a single repeat of the int32_t type is 256/sizeof(int32_t) = 64, mask = 64, and mask ∈ [1, 64]. Therefore, the input is valid. // repeatTime = 1. There are 64 elements in total. A single repeat can process 64 elements. Therefore, repeatTime = 1. // dstBlkStride, src0BlkStride, src1BlkStride = 1. Data is contiguously read and written in a single repeat. // dstRepStride, src0RepStride, src1RepStride = 8. Data is contiguously read and written between repeats. uint64_t mask = 64; AscendC::Add(dstLocal, src0Local, src1Local, mask, 1, { 1, 1, 1, 8, 8, 8 }); |
Result example:
Input (src0Local): [1 2 3 ... 64] Input (src1Local): [1 2 3 ... 64] Output (dstLocal): [2 4 6 ... 128]
The mask value is an array. The array length and the value range of the array elements are related to the operand data type. When the operand is 16-bit, the array length is 2, mask[0] and mask[1] ∈ [0, 264 – 1] and cannot be 0 at the same time. When the operand is 32-bit, the array length is 1 and mask[0] ∈ (0, 264 – 1]. When the operand is 64-bit, the array length is 1 and mask[0] ∈ (0, 232 – 1].
Example:
1 2 3 4 5 6 | // The data type is int16_t. uint64_t mask[2] = {6148914691236517205, 6148914691236517205}; // repeatTime = 1. There are 128 elements in total. A single repeat can process 128 elements. Therefore, repeatTime = 1. // dstBlkStride, src0BlkStride, src1BlkStride = 1. Data is contiguously read and written in a single repeat. // dstRepStride, src0RepStride, src1RepStride = 8. Data is contiguously read and written between repeats. AscendC::Add(dstLocal, src0Local, src1Local, mask, 1, { 1, 1, 1, 8, 8, 8 }); |
Result example:
Input (src0Local): [1 2 3 ... 64 ... 127 128] Input (src1Local): [1 2 3 ... 64 ...127 128] Output (dstLocal): [2 undefined 6 ... undefined ...254 undefined]
mask process:
mask = {6148914691236517205, 6148914691236517205} (Note: 6148914691236517205 indicates the 64-bit binary number 0b010101....01. mask is arranged from the least significant bit to the most significant bit.)

1 2 3 4 5 6 | // The data type is int32_t. uint64_t mask[1] = {6148914691236517205}; // repeatTime = 1. There are 64 elements in total. A single repeat can process 64 elements. Therefore, repeatTime = 1. // dstBlkStride, src0BlkStride, src1BlkStride = 1. Data is contiguously read and written in a single repeat. // dstRepStride, src0RepStride, src1RepStride = 8. Data is contiguously read and written between repeats. AscendC::Add(dstLocal, src0Local, src1Local, mask, 1, { 1, 1, 1, 8, 8, 8 }); |
Result example:
Input (src0Local): [1 2 3 ... 63 64] Input (src1Local): [1 2 3 ... 63 64] Output (dstLocal): [2 undefined 6 ... 126 undefined]
mask process:
mask = {6148914691236517205, 0} (Note: 6148914691236517205 indicates a 64-bit binary number 0b010101....01.)
