Scatter (ISASI)
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
x |
|
|
x |
|
|
√ |
|
|
√ |
|
|
x |
|
|
x |
Function Usage
Generates a new result tensor based on a given continuous input tensor, a destination address offset tensor, and the offset address, and distributes the input tensor to the result tensor.
Scatters elements in the source operand src to positions (specified by using dst_offset and base_addr) in the destination operand dst.
Prototype
- Computation of the first n data elements of a tensor
1 2
template <typename T> __aicore__ inline void Scatter(const LocalTensor<T>& dst, const LocalTensor<T>& src, const LocalTensor<uint32_t>& dstOffset, const uint32_t dstBaseAddr, const uint32_t count)
- High-dimensional tensor sharding computation
- Bitwise mask mode
1 2
template <typename T> __aicore__ inline void Scatter(const LocalTensor<T>& dst, const LocalTensor<T>& src, const LocalTensor<uint32_t>& dstOffset, const uint32_t dstBaseAddr, const uint64_t mask[], const uint8_t repeatTime, const uint8_t srcRepStride)
- Contiguous mask mode
1 2
template <typename T> __aicore__ inline void Scatter(const LocalTensor<T>& dst, const LocalTensor<T>& src, const LocalTensor<uint32_t>& dstOffset, const uint32_t dstBaseAddr, const uint64_t mask, const uint8_t repeatTime, const uint8_t srcRepStride)
- Bitwise mask mode
Parameters
|
Parameter |
Description |
|---|---|
|
T |
Operand data type. For the Atlas 350 Accelerator Card, the supported data types are uint8_t, int8_t, uint16_t, int16_t, half, bfloat16_t, uint32_t, int32_t, float, uint64_t, and int64_t. For the For the |
Restrictions
- For details about the operand address alignment requirements, see General Address Alignment Restrictions.
- For details about the constraints on operand address overlapping, see General Address Overlapping Restrictions.
- The offset addresses in dstOffset must be unique. If two or more offsets are the same, the behavior is unpredictable.
- For the Atlas 350 Accelerator Card, only the APIs that compute the first n data elements of a tensor are supported for the uint8_t and int8_t data types.
Examples
1 2 |
uint32_t m_elementCount = 128; AscendC::Scatter(dstLocal, srcLocal, dstOffsetLocal, (uint32_t)0, m_elementCount); // dstOffsetLocal stores the address offset of each element of the source operand in dst. |
Input dstOffsetLocal: [254 252 250 ... 4 2 0] Input srcLocal (128 data elements of the half type): [0 1 2 ... 125 126 127] Output dstGlobal: [127 126 125 ... 2 1 0]
