已关闭
[Bug-Report|缺陷反馈]: Eltwise 算子共性问题排查 #2627
zhangjinyang创建于 25 天前关闭于 14 天前
zhangjinyang
25 天前 评论:
25 天前 评论:
/assign


25 天前 将 ZJYzjy-shine 设为负责人
Zzhangjinyang
25 天前 关联了pull request:fix: Eltwise 算子多项缺陷修复(proto.h 缺 N / InferDataType 缺失 / attr index 偏移 / kernel 升精度 / tiling_key 冗余编码)
25 天前 关联了pull request:fix: Eltwise 算子多项缺陷修复(proto.h 缺 N / InferDataType 缺失 / attr index 偏移 / kernel 升精度 / tiling_key 冗余编码)
Zzhangjinyang
22 天前 修改标题为 “[Bug-Report|缺陷反馈]: Eltwise 算子共性问题排查”,原标题为“[Bug-Report|缺陷反馈]: Eltwise 算子多项缺陷修复(proto.h 缺 N / InferDataType 缺失 / attr index 偏移 / kernel 升精度 / tiling_key dtype 冗余编码)”
22 天前 修改标题为 “[Bug-Report|缺陷反馈]: Eltwise 算子共性问题排查”,原标题为“[Bug-Report|缺陷反馈]: Eltwise 算子多项缺陷修复(proto.h 缺 N / InferDataType 缺失 / attr index 偏移 / kernel 升精度 / tiling_key dtype 冗余编码)”
22 天前 修改了issue 的描述
22 天前 修改了issue 的描述
14 天前 关闭了 issue
14 天前 添加了label:resolved
Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
问题描述:
一、问题描述(必填)
Eltwise 算子共性问题排查
缺陷 1:def.cpp 缺少 N 属性声明,导致 autogen proto.h 丢失 REQUIRED_ATTR(N, Int)
op_host/eltwise_def.cpp未声明N属性,而op_graph/eltwise_proto.h已声明REQUIRED_ATTR(N, Int)。编译系统从 OpDef 生成安装的 proto.h 时会丢弃 N,导致:set_attr_N()报编译错误:has no member named 'set_attr_N'修复:def.cpp 添加
this->Attr("N").AttrType(REQUIRED).Int()。缺陷 2:缺少 InferDataType 实现
op_graph/目录下缺少eltwise_graph_infer.cpp,InferDataType 未注册,GE 图编译时输出 dtype 推导缺失。修复:新增
eltwise_graph_infer.cpp,实现InferDataTypeForEltwise(输出 dtype = 第一个输入 dtype)。缺陷 3:tiling 代码属性 index 偏移
eltwise_tiling_arch35.cpp中GetModeAttr用固定 index 0 读取 mode,但由于 proto.h 中REQUIRED_ATTR(N, Int)在 index 0,实际读到的是 N(输入个数)而非 mode,表现为invalid mode 3。同理FillCoeff的 coeff index 也有偏移。修复:改为 try-both-index 策略——读 val0 和 val1,用 inputNum 消歧(如果 val0==inputNum 则 val0 是 N,mode=val1)。coeff 用同样的 inputNum 判断 hasN,hasN 时 coeffIdx=2,否则 coeffIdx=1。
缺陷 4:kernel 升精度导致 FP16/BF16 精度不一致
eltwise.h中 FP16/BF16 输入先 Cast 到 FP32 计算,再 Cast 回原 dtype。但 golden 不升精度(原 dtype 链式计算),两者精度策略不一致,导致 5 条 FP16/BF16 大输入数用例 DYN FAIL。修复:去掉升精度分支。BF16 用
ReinterpretCast<uint16_t>+Duplicate(uint16_t)处理零值填充和 coeff 标量(bisheng 编译器不支持直接构造 bfloat16_t)。所有计算在原 dtype 上完成。缺陷 5:tiling_key 冗余编码 dtype
eltwise_tiling_key.h用ASCENDC_TPL_DATATYPE_DECL(D_T, ...)编码 dtype,但 def.cpp 已通过DataType({ge::DT_FLOAT16, ge::DT_BF16, ge::DT_FLOAT})声明 dtype,属于重复编码。修复:去掉
DATATYPE_DECL,只保留UINT_DECL(MODE)。编译变体数量不变(3 dtype × 3 mode = 9),tiling_key 更简洁。缺陷 6:kernel 模板冗余 dtype 模板参数
eltwise.cpp的 kernel 模板为<typename D_T, int MODE>,dtype 由模板参数驱动,与 def 驱动 dtype 模式不一致。修复:改为
template <int MODE>+DTYPE_X宏,dtype 由 def 的ASCENDC_TPL_SEL_PARAM注入。二、环境信息(可选)
三、重现步骤(可选)
-c -d双路)set_attr_N()编译报错四、预期结果(可选)
6 项缺陷全部修复后,211 条 GEIR 用例 const + dynamic 双路全绿(422 个结果),负向异常用例预期 FAIL/SKIP。