SetVectorMask
功能说明
在vector计算时设置Mask,配合不同的MaskMode进行设置。
- 当MaskMode::COUNTER时,对应Mask的Counter模式,详情请参见SetMaskCount功能说明。
calCount表示counter模式下参与计算的元素个数,该场景接口传入参数如下:
SetVectorMask(int32_t len):len = calCount; SetVectorMask(const uint64_t maskHigh, const uint64_t maskLow):maskHigh = 0,maskLow = calCount;
- 当MaskMode::NORMAL时,对应Mask的Normal模式,详情请参见SetMaskNorm功能说明。
- SetVectorMask(int32_t len)对应Mask的连续模式。
- SetVectorMask(const uint64_t maskHigh, const uint64_t maskLow)对应Mask的逐bit模式。
上述两种模式的说明请参见Mask参数。
函数原型
template <typename T, MaskMode mode = MaskMode::NORMAL>
__aicore__ static inline void SetVectorMask(const uint64_t maskHigh, const uint64_t maskLow);
template <typename T, MaskMode mode = MaskMode::NORMAL>
__aicore__ static inline void SetVectorMask(int32_t len);
参数说明
参数名 |
输入/输出 |
描述 |
---|---|---|
maskHigh |
输入 |
Normal模式:高位mask,直接透传Mask的高位参数。 Counter模式:需要置0,本入参不生效。 |
maskLow |
输入 |
Normal模式:低位mask,直接透传Mask的低位参数。 Counter模式:参与计算的元素个数。 |
len |
输入 |
Normal/Counter模式:参与计算的元素个数。 |
MaskMode |
输入 |
设置的Mask模式,有两种模式
|
返回值
无
支持的型号
Atlas 训练系列产品
Atlas推理系列产品AI Core
Atlas推理系列产品Vector Core
Atlas A2训练系列产品/Atlas 800I A2推理产品
约束说明
当vector指令的isSetMask参数为false时生效,使用完成后用ResetMask恢复Mask值为默认值。
调用示例
可结合SetMaskCount与SetMaskNorm使用,先设置Mask的模式再设置Mask,以下示例设置的是half类型的Mask:
// normal模式 SetMaskNorm(); SetVectorMask<half, MaskMode::NORMAL>(0xffffffffffffffff, 0xffffffffffffffff); // 逐bit模式 SetMaskNorm(); SetVectorMask<half, MaskMode::NORMAL>(128); // 连续模式 // counter模式 SetMaskCount(); SetVectorMask<half, MaskMode::COUNTER>(128); SetMaskCount(); SetVectorMask<half, MaskMode::COUNTER>(0, 128);