QuantMatmulV4 的参数校验逻辑集中在 matmul/quant_batch_matmul_v3/op_api/aclnn_quant_matmul_v4.cpp 中,文件内同时承载大量常量、tuple 索引、dtype/format 判断、A8W4/MX/TCG 场景识别和 NZ shape 工具函数,维护成本较高,也不利于后续复用。
matmul/quant_batch_matmul_v3/op_api/aclnn_quant_matmul_v4.cpp
同时,A8W4/MX 相关公共判断函数需要对可选 tensor 和 scale 做统一的空指针保护,避免后续场景识别或 format 判断中出现空指针访问风险。arch35 kernel 与 tiling key 对 Basic/Tensor API、MX without-batch 场景的宏判断也需要收敛,保证编译期路由逻辑一致。
ops-nn matmul 模块代码整改需求,来源于 QuantBatchMatmulV3 / aclnnQuantMatmulV4 维护过程中的超大函数拆分和公共能力沉淀。关联 PR:https://gitcode.com/cann/ops-nn/pull/6889
aclnn_quant_matmul_v4.cpp
IS_BLAZE
matmul/quant_batch_matmul_v3/op_api/quant_matmul_v4_common.h
quant_matmul_v4
x1
x2
scale
x1Scale
x2Scale
quant_batch_matmul_v3_apt_tiling_key.h
quant_batch_matmul_v3.cpp
Backgroud(背景信息)
QuantMatmulV4 的参数校验逻辑集中在
matmul/quant_batch_matmul_v3/op_api/aclnn_quant_matmul_v4.cpp中,文件内同时承载大量常量、tuple 索引、dtype/format 判断、A8W4/MX/TCG 场景识别和 NZ shape 工具函数,维护成本较高,也不利于后续复用。同时,A8W4/MX 相关公共判断函数需要对可选 tensor 和 scale 做统一的空指针保护,避免后续场景识别或 format 判断中出现空指针访问风险。arch35 kernel 与 tiling key 对 Basic/Tensor API、MX without-batch 场景的宏判断也需要收敛,保证编译期路由逻辑一致。
Origin(信息来源)
ops-nn matmul 模块代码整改需求,来源于 QuantBatchMatmulV3 / aclnnQuantMatmulV4 维护过程中的超大函数拆分和公共能力沉淀。关联 PR:https://gitcode.com/cann/ops-nn/pull/6889
Benefit / Necessity (价值/作用)
aclnn_quant_matmul_v4.cpp超大函数/超大文件的维护成本,提升代码可读性。IS_BLAZE、MX without-batch/tensor API 的判断边界,降低编译期路由不一致风险。Design(设计方案)
matmul/quant_batch_matmul_v3/op_api/quant_matmul_v4_common.h,沉淀 V4 参数校验所需的常量、tuple 类型别名和公共 helper,包括 A8W4/MX/TCG 场景判断、NZ K0 选择、对齐检查、format 判断等。aclnn_quant_matmul_v4.cpp引入公共头文件并复用quant_matmul_v4命名空间中的公共定义,移除文件内重复声明。x1、x2、scale、x1Scale、x2Scale等指针的 nullptr 判断。IS_BLAZE宏定义前移到quant_batch_matmul_v3_apt_tiling_key.h,供 kernel 与 tiling key 统一使用,并补充 MX without-batch tiling key 条件。quant_batch_matmul_v3.cpp中 arch35 kernel 分支代码格式,保持原有功能路径清晰可维护。