Where
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Selects elements from two source operands based on specified conditions to generate a target operand. Both source operands can be LocalTensor or scalar.

Prototype
1 2 | template <typename T, typename U, typename S, typename V> __aicore__ inline void Where(const LocalTensor<T>& dst, const U& src0, const S& src1, const LocalTensor<V>& condition, const uint32_t count) |
Parameters
Parameter |
Description |
|---|---|
T |
Data type of the destination operand. For the Atlas 350 Accelerator Card, the supported data types are bool, int8_t, uint8_t, int16_t, uint16_t, half, bfloat16_t, int32_t, uint32_t, float, int64_t, and uint64_t. |
U |
LocalTensor or Scalar type. The type is automatically inferred based on the input parameter src0. Developers do not need to configure this parameter. Ensure that the data type of src0 is the same as that of the destination operand. |
S |
LocalTensor or Scalar type. The type is automatically inferred based on the input parameter src1. Developers do not need to configure this parameter. Ensure that the data type of src1 is the same as that of the destination operand. |
V |
Condition data type. Currently, only the bool data type is supported. |
Parameter |
Type |
Description |
|---|---|---|
dst |
Output |
Destination operand. The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT. |
src0, src1 |
Input |
Source operand. The type can be Scalar or LocalTensor. When the type is LocalTensor, the supported TPosition is VECIN, VECCALC, or VECOUT. The source and destination operands must have the same data type. |
condition |
Input |
Condition operand. The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT. |
count |
Input |
Number of elements involved in the computation. |
Returns
None
Constraints
- The source operand address must not overlap the destination operand address.
- For details about the alignment requirements of the operand address offset, see General Description and Restrictions.
Examples
1 2 3 4 | AscendC::LocalTensor<half> dst, src0, src1; AscendC::LocalTensor<bool> condition; uint32_t count = 512; // Number of elements involved in computation AscendC::Where(dst, src0, src1, condition, count); |
Result example:
1 2 3 4 5 6 7 8 | Input (src0): [1, 2, 3, ... 511, 512] Input (src1): [-1, -2, -3, ... -511, -512] Condition input data (condition). If the value is 0, src1 is selected. If the value is 1, src0 is selected. [0, 1, 0, ... 0, 1] Output (dst): [-1, 2, -3, ... -511, 512] |