GetIBShareNormConfig
产品支持情况
功能说明
用于配置IBShare模板的参数,获取自定义IBShare模板。IBShare模板的介绍请参考表 模板特性。
函数原型
__aicore__ constexpr MatmulConfig GetIBShareNormConfig(const bool intrinsicsLimit = false, const bool batchLoop = false, const bool isVecND2NZ = false, const BatchMode bmmMode = BatchMode::BATCH_LESS_THAN_L1, const bool isDoubleCache = false, const bool enUnitFlag = true)
参数说明
本接口的所有参数用于设置MatmulConfig结构体中的参数,其中互相对应的参数的功能作用相同。
表 1 接口参数说明
|
当左矩阵或右矩阵在单核上内轴(即尾轴)大于等于65535(元素个数)时,是否使能循环执行数据从Global Memory到L1 Buffer的搬入。例如,左矩阵A[M, K],单核上的内轴数据singleCoreK大于65535,配置该参数为true后,API内部通过循环执行数据的搬入。参数取值如下: |
||
|
是否多Batch输入多Batch输出。仅对BatchMatmul有效,使能该参数后,仅支持Norm模板,且需调用IterateNBatch实现多Batch输入多Batch输出。参数取值如下: |
||
|
使能通过vector指令进行ND2NZ。使能时需要设置SetLocalWorkspace。参数取值如下: |
||
用于设置参数batchMode。该参数用于BatchMatmul场景。 BatchMatmul场景中Layout类型为NORMAL时,设置BatchMatmul输入A/B矩阵的多batch数据总和与L1 Buffer的大小关系。参数取值如下: |
||
|
开启IBShare模板后,在L1 Buffer上是否同时缓存两块数据。参数取值如下: |
||
|
使能UnitFlag功能,使计算与搬运流水并行,提高性能。Norm, IBShare下默认使能,MDL下默认不使能。参数取值如下: |
返回值说明
约束说明
IBShare模板当前仅适用于MIX场景,不支持纯CUBE场景。
调用示例
constexpr MatmulConfig MM_CFG = GetIBShareNormConfig();
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half> aType;
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half, true, LayoutMode::NONE, true> bType;
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> cType;
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> biasType;
AscendC::Matmul<A_TYPE, B_TYPE, C_TYPE, BIAS_TYPE, MM_CFG> mm;
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
mm.SetBias(gm_bias);
mm.IterateAll(gm_c);