rt2.0 架构下,QuantBatchMatmulV4、WeightQuantBatchMatmulV2、TransData 三个算子的 infershape/inferDtype 正在从 canndev 仓(rt1.0)迁移至开源仓(rt2.0)。其中两算子的 infershape 已在 op_host 目录存在,但 inferDtype 缺失:
REQUIRED_ATTR(dtype, Int)
InferDataTypeQuantBatchMatmulV4
dtype
quant_scale
InferDataTypeForWeightQuantBatchMatmulV2
按开源仓 op_graph 目录规范新增 <op>_graph_infer.cpp,注册方式 IMPL_OP_INFERSHAPE(X).InferDataType(...),推导逻辑与 canndev 原版保持一致(仅适配头文件引用),并保留进入/退出日志便于定位:
<op>_graph_infer.cpp
IMPL_OP_INFERSHAPE(X).InferDataType(...)
matmul/quant_batch_matmul_v4/op_graph/quant_batch_matmul_v4_graph_infer.cpp
y dtype = static_cast<ge::DataType>(dtype attr[0])
matmul/weight_quant_batch_matmul_v2/op_graph/weight_quant_batch_matmul_v2_graph_infer.cpp
cmake 自动收集 op_graph/*.cpp,无需修改构建脚本。
/assign @zhangquanxin
Background(背景信息)
rt2.0 架构下,QuantBatchMatmulV4、WeightQuantBatchMatmulV2、TransData 三个算子的 infershape/inferDtype 正在从 canndev 仓(rt1.0)迁移至开源仓(rt2.0)。其中两算子的 infershape 已在 op_host 目录存在,但 inferDtype 缺失:
REQUIRED_ATTR(dtype, Int)声明(支持 DT_FLOAT16/DT_BF16),与输入 dtype(FP8/INT8 等)不同,图模式下若不注册 InferDataType,默认推导会得到错误的输出 dtype。canndev rt1.0 侧已有InferDataTypeQuantBatchMatmulV4(matmul_infer_fns.cc),迁移后开源仓需具备对等能力;dtypeattr 与quant_scale可选输入(C8 场景)共同决定(INT8 或同 x dtype)。canndev rt1.0 侧已有InferDataTypeForWeightQuantBatchMatmulV2,迁移后开源仓需具备对等能力。Benefit / Necessity(价值/作用)
Design(设计方案)
按开源仓 op_graph 目录规范新增
<op>_graph_infer.cpp,注册方式IMPL_OP_INFERSHAPE(X).InferDataType(...),推导逻辑与 canndev 原版保持一致(仅适配头文件引用),并保留进入/退出日志便于定位:matmul/quant_batch_matmul_v4/op_graph/quant_batch_matmul_v4_graph_infer.cpp:y dtype = static_cast<ge::DataType>(dtype attr[0]);matmul/weight_quant_batch_matmul_v2/op_graph/weight_quant_batch_matmul_v2_graph_infer.cpp:迁移 canndevInferDataTypeForWeightQuantBatchMatmulV2全部逻辑(attr 索引 3、quant_scale 输入索引 4 的 C8 判断、x dtype 兜底)。cmake 自动收集 op_graph/*.cpp,无需修改构建脚本。