Brcb
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
√ |
|
x |
|
x |
Function Usage
Extracts eight elements from a given input tensor each time and fills them in eight data blocks (32 bytes) in the result tensor. Each element corresponds to a data block.
Prototype
1 2 | template <typename T> __aicore__ inline void Brcb(const LocalTensor<T>& dst, const LocalTensor<T>& src0, const uint8_t repeatTime, const BrcbRepeatParams& repeatParams) |
Parameters
Parameter |
Description |
|---|---|
T |
Operand data type. For the Atlas 350 Accelerator Card, the supported data types are int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, half, float, bfloat16_t, uint64_t, and int64_t. For the For the For the |
Parameter |
Input/Output |
Meaning |
|---|---|---|
dst |
Output |
Destination operand. The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT. The start address of LocalTensor must be 32-byte aligned. |
src0 |
Input |
Source operand. The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT. The start address of LocalTensor must be 32-byte aligned. Its data type must match that of dst. Eight elements are read from src0 in each iteration. Therefore, the total number of elements in src0 must be no less than repeatTime multiplied by 8. |
repeatTime |
Input |
Number of instruction repeats. Eight data blocks are collected in each repeat. The value range is [0, 255] |
repeatParams |
Input |
Instruction iteration parameters. The type is BrcbRepeatParams. For details about the definition, see ${INSTALL_DIR}/include/ascendc/basic_api/interface/kernel_struct_brcb.h. Replace ${INSTALL_DIR} with the CANN installation path. dstBlkStride and dstRepStride can be set by users. For details about the parameters, see Table 3. |
Parameter |
Meaning |
|---|---|
dstBlkStride |
Address stride of the vector destination operand between different data blocks in a single repeat. Note: When dstBlkStride is set to 0, the value 1 is used by default. |
dstRepStride |
Address stride of the vector destination operand for the same data block between adjacent repeats |
blockNumber |
Reserved parameter. This parameter is reserved for future functions. You can use the default value. |
src0BlkStride |
|
src1BlkStride |
|
src0RepStride |
|
src1RepStride |
|
repeatStrideMode |
|
strideSizeMode |
Returns
None
Restrictions
- For details about the operand address alignment requirements, see General Address Alignment Restrictions.
- Overlapping memory between src0 and dst is not supported.
- For the
Atlas inference product AI Core, reserve an 8 KB Unified Buffer to serve as a temporary data storage area for the API.
Examples
1 2 3 4 5 | // repeatTime = 4, 128 elements one repeat, 512 elements total // The data type of srcLocal is half, and the data type of dstLocal is half. // dstBlkStride = 1, no gap between blocks in one repeat // dstRepStride = 8, no gap between repeats AscendC::Brcb(dstLocal, srcLocal, 4, {1,8}); |
Result example:
Input (srcLocal): [1 2 3 ... 16] Initial value of output data (dstLocal): [0. 0. 0. 0. 0. 0. ... 0.] Output (dstLocal) after Brcb computation: [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ... 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16]