Closed
[Requirement|需求建议]: GLU 算子补齐 op_graph InferDataType 推导注册 #8020
esok11Add on 18 days agoClosed at 18 days ago
18 days ago Added label: requirement
18 days ago Assign esok11 as responsible person
18 days ago Close issue
18 days ago Added label: resolved


Backgroud(背景信息)
GLU 算子位于
activation/glu,op_graph 目录下已有glu_proto.h(REG_OP 原型,声明 y “Has the same type as x”)和空的fusion_pass/,host 侧只有op_host/glu_infershape.cpp中的IMPL_OP_INFERSHAPE(GLU)提供 InferShape,op_graph 目录缺少 InferDataType 推导注册(无*_graph_infer.cpp)。RT2.0 图模式下 GLU 缺少输出 dtype 推导能力。Origin(信息来源)
CANN ops-nn 仓库 RT2.0 图模式推导补齐需求(GLU 算子 op_graph InferDataType 注册),由 GLU 算子维护流程提出。
Benefit / Necessity (价值/作用)
补齐后图模式下 GLU 的输出 y 可由注册信息推导为与输入 x 相同的 dtype(
op_host/glu_def.cpp中 x/y 均注册DT_FLOAT16、DT_BF16、DT_FLOAT),与既有的 InferShape 注册一起构成完整的图侧推导能力,避免依赖默认推导或下游手工指定;改动仅局限在 op_graph,不影响 op_host/aclnn 直调通路。Design(设计方案)
新增
activation/glu/op_graph/glu_graph_infer.cpp:GLU_IN_X = 0(输入 x)、GLU_OUT_Y = 0(输出 y)。InferDataTypeForGlu(gert::InferDataTypeContext* context):OP_LOGE("GLU", "InferDataType context is nullptr.")并返回ge::GRAPH_FAILED;OP_LOGD(context->GetNodeName(), "Begin to do InferDataTypeForGlu");const ge::DataType dtype = context->GetInputDataType(GLU_IN_X);ge::graphStatus ret = context->SetOutputDataType(GLU_OUT_Y, dtype);OP_LOGD(context->GetNodeName(), "End to do InferDataTypeForGlu"),返回ret。IMPL_OP(GLU).InferDataType(InferDataTypeForGlu);(namespace ops)。op_host/glu_def.cpp、op_host/glu_infershape.cpp,不新增 InferFormat 注册;op_graph/CMakeLists.txt无需改动,源文件由add_graph_plugin_sources()的file(GLOB_RECURSE ... op_graph/*.cpp)自动收集。关联 PR:https://gitcode.com/cann/ops-nn/pull/13469