[==========] 116 tests from 19 test suites ran.
[ PASSED ] 116 tests.
[ OK ] relu6grad.relu6grad_infer_datatype
[ OK ] MultilabelMarginLossInferShapeTest.multilabelmarginloss_infer_datatype
[ OK ] PoissonNllLossInfershapeTest.poissonnllloss_infer_datatype
[ OK ] LambApplyOptimizerAssignProtoTest.lambapplyoptimizerassign_infer_datatype
[ OK ] LambApplyWeightAssignProtoTest.lambapplyweightassign_infer_datatype
[ OK ] LambNextMVProtoTest.lambnextmv_infer_datatype
[ OK ] LambNextMVWithDecayProtoTest.lambnextmvwithdecay_infer_datatype
[ OK ] LambNextRightProtoTest.lambnextright_infer_datatype
[ OK ] LambUpdateWithLrProtoTest.lambupdatewithlr_infer_datatype
[ OK ] LambUpdateWithLrV2ProtoTest.lambupdatewithlrv2_infer_datatype
Describe the current behavior / 问题描述
Relu6Grad、LambApplyOptimizerAssign、LambApplyWeightAssign、LambNextMV、LambNextMVWithDecay、LambNextRight、LambUpdateWithLr、LambUpdateWithLrV2、MultilabelMarginLoss、PoissonNllLoss 这 10 个算子,在各自的
op_host/*_infershape.cpp中只做了IMPL_OP_INFERSHAPE(<OpType>).InferShape(...)注册,没有注册InferDataType;在op_graph/下也没有IMPL_OP(<OpType>).InferDataType(...)的注册。这 10 个算子的 op_graph 原型、op_host def 与 op_kernel 均齐全,属于有 GE 图通路的算子,因此图编译时其输出 dtype 缺少显式推导来源。
对照:以当前 master 基线计,仓内 op_host 的
IMPL_OP_INFERSHAPE(...).InferDataType(...)写法共 323 个文件,op_graph 的IMPL_OP(...).InferDataType(...)写法共 90 个文件,本批 10 个算子两种写法均无。Environment / 环境信息
b405035cb(fix(bnll): improve log1p precision)build.sh -u --ophost --soc=ascend950)Steps to reproduce the issue / 重现步骤
检出 cann/ops-nn master(基线
b405035cb)对上述任一算子检查注册面,例如:
grep -n "InferDataType" activation/relu6_grad/op_host/relu6_grad_infershape.cpp grep -rn "InferDataType" activation/relu6_grad/op_graph/两条命令均无输出,即该算子既没有在 op_host 也没有在 op_graph 注册 InferDataType。其余 9 个算子(
optim/lamb_*、loss/multilabel_margin_loss、loss/poisson_nll_loss)同理。auto opImpl = gert::OpImplRegistry::GetInstance().GetOpImpl("Relu6Grad"); // opImpl->infer_datatype 为 nullptrDescribe the expected behavior / 预期结果
这 10 个算子应注册
InferDataType,即gert::OpImplRegistry::GetInstance().GetOpImpl("<OpType>")->infer_datatype非空,且各输出的 dtype 按算子语义正确推导。其中 MultilabelMarginLoss 的 is_target 输出应推导为 INT32(跟随 target),不能跟随 x,否则图上会把 INT32 的 is_target 推成浮点。Related log / screenshot / 日志 / 截图
修复前,上述 grep 命令无任何输出(即无 InferDataType 注册)。
修复后,
bash build.sh -u --ophost --soc=ascend950 --ops=<上述 10 个算子>的执行结果:新增用例中的
ASSERT_NE(dataTypeFunc, nullptr)即为该注册生效的直接证据。Special notes for this issue / 备注
vfusion/normalize_bbox/op_graph/normalize_bbox_graph_infer.cpp中以IMPL_OP(NormalizeBBox).InferDataType(...)注册,只是没有写在IMPL_OP_INFERSHAPE块里