SetUserDefInfo
产品支持情况
- Ascend 950PR/Ascend 950DT:支持
- Atlas A3 训练系列产品/Atlas A3 推理系列产品:支持
- Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持
- Atlas 200I/500 A2 推理产品:不支持
- Atlas 推理系列产品AI Core:不支持
- Atlas 推理系列产品Vector Core:不支持
- Atlas 训练系列产品:不支持
- Kirin X90:支持
功能说明
启用模板参数MatmulCallBackFunc(自定义回调函数)时,设置算子tiling地址,用于回调函数使用,该接口仅需调用一次。
函数原型
Text
__aicore__ inline void SetUserDefInfo(const uint64_t tilingPtr)
参数说明
表1 参数说明
| 参数名 | 输入/输出 | 描述 |
|---|---|---|
| tilingPtr | 输入 | 设置的算子tiling地址。 |
返回值说明
无
约束说明
- 若回调函数中需要使用tilingPtr参数时,必须调用此接口;若回调函数不使用tilingPtr参数,无需调用此接口。
- 当开启MixDualMaster(双主模式)场景时,即模板参数enableMixDualMaster设置为true,不支持使用该接口。
调用示例
Text
// 用户自定义回调函数
void DataCopyOut(
const __gm__ void* gm, const LocalTensor<int8_t>& co1Local, const void* dataCopyOutParams, const uint64_t tilingPtr,
const uint64_t dataPtr);
void CopyA1(
const LocalTensor<int8_t>& aMatrix, const __gm__ void* gm, int row, int col, int useM, int useK,
const uint64_t tilingPtr, const uint64_t dataPtr);
void CopyB1(
const LocalTensor<int8_t>& bMatrix, const __gm__ void* gm, int row, int col, int useK, int useN,
const uint64_t tilingPtr, const uint64_t dataPtr);
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half> aType;
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half> bType;
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> cType;
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> biasType;
AscendC::Matmul<aType, bType, cType, biasType, CFG_NORM, MatmulCallBackFunc<DataCopyOut, CopyA1, CopyB1>> mm;
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
uint64_t tilingPtr = reinterpret_cast<uint64_t>(tiling);
// 设置算子tiling地址,用于回调函数使用,该接口仅需调用一次
mm.SetUserDefInfo(tilingPtr);
mm.SetTensorA(gmA);
mm.SetTensorB(gmB);
mm.IterateAll();