GetUBSizeInBytes
产品支持情况
功能说明
获取UB空间的大小,单位为byte。开发者根据UB的大小来计算循环次数等参数值。
函数原型
__aicore__ inline constexpr uint32_t GetUBSizeInBytes()
参数说明
无
返回值说明
UB空间的大小,单位为byte。
约束说明
无
调用示例
本调用示例通过GetUBSizeInBytes获取的UB空间大小,来计算tileNum的值。完整的算子样例请参考:算子样例。
#include "kernel_operator.h"
uint32_t totalLength = 16384;
uint32_t tileLength = AscendC::GetUBSizeInBytes() / sizeof(half) / 2;
if (totalLength < tileLength) {
tileLength = totalLength;
}
uint32_t tileNum = totalLength / tileLength;