matmul高阶api相同输入输出不同
收藏回复举报
matmul高阶api相同输入输出不同
t('forum.solved') 已解决
新人帖
发表于2026-07-03 10:36:22
0 查看
怀疑是高阶配置有啥设置错了,当前开发部分代码如下,打印结果不如预期:

    using ATypeQK = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using BTypeQK = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, true>;

    using CTypeQK = MatmulType<AscendC::TPosition::CO1, CubeFormat::NZ, float>;

    using ATypeQH = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using BTypeQH = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using CTypeQH = MatmulType<AscendC::TPosition::GM, CubeFormat::ND_ALIGN, half>;

    using ATypeAV = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using BTypeAV = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using CTypeAV = MatmulType<AscendC::TPosition::GM, CubeFormat::ND_ALIGN, half>;

    using BIAS_TYPE = matmul::MatmulType<TPosition::GM, CubeFormat::ND, bfloat16_t>;

                printf("-----------------C2-----------------\n");

                printf("-----------------C2输入 q矩阵-----------------\n");

                DumpTensor(gmQTensor[cube23Off.qkGmBase + cube23Off.qkHeadInner], 000, (uint32_t)200);

                printf("-----------------C2输入 h矩阵-----------------\n");

                DumpTensor(gmHTensor[cube23Off.hOffset], 000, (uint32_t)200);

               

                mmQH.SetOrgShape(cube23Off.blockTokens, vHeadDim_m, kNumHead_m * kHeadDim_m, kHeadDim_m, 0);

                mmQH.SetSingleShape(cube23Off.blockTokens, vHeadDim_m, kHeadDim_m);

                mmQH.SetTensorA(gmQTensor[cube23Off.qkGmBase + cube23Off.qkHeadInner]);

                mmQH.SetTensorB(gmHTensor[cube23Off.hOffset]);

                mmQH.IterateAll(gmHWork[cube23Off.hvWorkOffset]);

                mmQH.End();

                printf("-----------------C2结果-----------------\n");

                DumpTensor(gmHWork[cube23Off.hvWorkOffset], 000, (uint32_t)200);

预期代码的matmul配置:

    using ATypeQK = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using BTypeQK = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, true>;

    using CTypeQK = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half>;

    using ATypeQH = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using BTypeQH = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using CTypeQH = MatmulType<AscendC::TPosition::GM, CubeFormat::ND_ALIGN, half>;

    using ATypeAV = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using BTypeAV = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, bfloat16_t, false>;

    using CTypeAV = MatmulType<AscendC::TPosition::GM, CubeFormat::ND_ALIGN, half>;

    using BIAS_TYPE = matmul::MatmulType<TPosition::GM, CubeFormat::ND, bfloat16_t>;

上面的打印部分,输入q和h打印出来是一样的,但是结果是错的

我要发帖子