Max
产品支持情况
产品 |
是否支持 |
|---|---|
Atlas 350 加速卡 |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
功能说明
根据mask对源操作数srcReg0、srcReg1进行按元素求最大值操作,将结果写入目的操作数dstReg。计算公式如下:

函数原型
template <typename T = DefaultType, MaskMergeMode mode = MaskMergeMode::ZEROING, typename U> __simd_callee__ inline void Max(U& dstReg, U& srcReg0, U& srcReg1, MaskReg& mask)
参数说明
参数名 |
描述 |
|---|---|
T |
操作数数据类型。 Atlas 350 加速卡,支持的数据类型为:uint8_t/int8_t/uint16_t/int16_t/uint32_t/int32_t/uint64_t/int64_t/half/float/bfloat16_t |
mode |
选择MERGING模式或ZEROING模式。
|
U |
目的操作数的RegTensor类型,例如RegTensor<half>,由编译器自动推导,用户不需要填写。 |
返回值说明
无
约束说明
输入srcReg0为-0, srcReg1为+0的情况下,输出dstReg为+0。
调用示例
template<typename T>
__simd_vf__ inline void MaxVf(__ubuf__ T* dstAddr, __ubuf__ T* src0Addr, __ubuf__ T* src1Addr, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> srcReg0;
AscendC::Reg::RegTensor<T> srcReg1;
AscendC::Reg::RegTensor<T> dstReg;
AscendC::Reg::MaskReg mask; ;
for (uint16_t i = 0; i < repeatTimes; i++) {
mask = AscendC::Reg::UpdateMask<T>(count);
AscendC::Reg::LoadAlign(srcReg0, src0Addr + i * oneRepeatSize);
AscendC::Reg::LoadAlign(srcReg1, src1Addr + i * oneRepeatSize);
AscendC::Reg::Max(dstReg, srcReg0, srcReg1, mask);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, dstReg, mask);
}
}
父主题: 基础算术