产品 |
是否支持 |
|---|---|
Ascend 950PR/Ascend 950DT |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
支持Scalar和Tensor两种模式:
template <typename T = DefaultType, typename U, typename S> __simd_callee__ inline void Duplicate(S& dstReg, U scalarValue);
template <typename T = DefaultType, MaskMergeMode mode = MaskMergeMode::ZEROING, typename U, typename S> __simd_callee__ inline void Duplicate(S& dstReg, U scalarValue, MaskReg& mask);
template <typename T = DefaultType, HighLowPart pos = HighLowPart::LOWEST, MaskMergeMode mode = MaskMergeMode::ZEROING, typename S> __simd_callee__ inline void Duplicate(S& dstReg, S& srcReg, MaskReg& mask)
参数名 |
描述 |
|---|---|
T |
操作数数据类型。 Ascend 950PR/Ascend 950DT,支持的数据类型为:bool、int8_t、uint8_t、fp4x2_e2m1_t、fp4x2_e1m2_t、hifloat8_t、fp8_e5m2_t、fp8_e4m3fn_t、fp8_e8m0_t、int16_t、uint16_t、half、bfloat16_t、int32_t、uint32_t、float、complex32、int64_t、uint64_t、complex64。 |
U |
scalar的数据类型。 Ascend 950PR/Ascend 950DT,支持的数据类型为:bool、int8_t、uint8_t、int16_t、uint16_t、half、bfloat16_t、int32_t、uint32_t、float、complex32、int64_t、uint64_t、complex64。 |
mode |
选择MERGING模式或ZEROING模式。
|
pos |
默认为LOWEST,表示将srcReg中的最低位广播至dstReg(暂不支持其他取值)。 |
S |
目的操作数的RegTensor类型, 例如RegTensor<half>,由编译器自动推导,用户不需要填写。 |
参数名 |
输入/输出 |
描述 |
|---|---|---|
dstReg |
输出 |
目的操作数。 类型为RegTensor。 |
scalarValue |
输入 |
源操作数。 类型为标量。 |
srcReg |
输入 |
源操作数。 类型为RegTensor。 |
mask |
输入 |
源操作数元素操作的有效指示,详细说明请参考MaskReg。 |
dstReg数据类型 |
scalar/srcReg数据类型 |
|---|---|
bool |
bool |
int8_t |
int8_t |
uint8_t |
uint8_t |
fp4x2_e2m1_t |
int8_t |
fp4x2_e1m2_t |
int8_t |
hifloat8_t |
int8_t |
fp8_e5m2_t |
int8_t |
fp8_e4m3fn_t |
int8_t |
fp8_e8m0_t |
int8_t |
int16_t |
int16_t |
uint16_t |
uint16_t |
half |
half |
bfloat16_t |
bfloat16_t |
int32_t |
int32_t |
uint32_t |
uint32_t |
float |
float |
complex32 |
complex32 |
int64_t |
int64_t |
uint64_t |
uint64_t |
complex64 |
complex64 |
无
template<typename T>
__simd_vf__ inline void DuplicateVF(__ubuf__ T* dstAddr, T scalarValue, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> dstReg;
AscendC::Reg::MaskReg mask = AscendC::Reg::CreateMask<T>();
for (uint16_t i = 0; i < repeatTimes; i++) {
AscendC::Reg::Duplicate(dstReg, scalarValue);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, dstReg, mask);
}
}
template<typename T>
__simd_vf__ inline void DuplicateVF(__ubuf__ T* dstAddr, T scalarValue, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
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(srcReg, src0Addr + i * oneRepeatSize);
AscendC::Reg::Duplicate(dstReg, scalarValue, mask);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, dstReg, mask);
}
}
template<typename T>
__simd_vf__ inline void DuplicateVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> srcReg;
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(srcReg, src0Addr + i * oneRepeatSize);
AscendC::Reg::Duplicate(dstReg, srcReg, mask);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, dstReg, mask);
}
}