未验证 提交 bfee398b 编写于 作者: Z zhoutianzi666 提交者: GitHub

[Inference] fix preln_residual_bias_fuse_pass bug in TNT_small model (#46178)

* fix preln_residual_bias_fuse_pass bug in TNT_small model 
上级 c8746024
......@@ -143,10 +143,7 @@ void PrelnResidualBiasFusePass::ApplyImpl(ir::Graph *graph) const {
LOG(WARNING) << "The subgraph is empty.";
return;
}
if (!IsCompat(subgraph, graph)) {
LOG(WARNING) << "preln_residual_bias pass in op compat failed.";
return;
}
VLOG(4) << "handle PrelnResidualBias fuse";
GET_IR_NODE_FROM_SUBGRAPH(
elementwise_bias, elementwise_bias, fused_pattern);
......@@ -164,6 +161,21 @@ void PrelnResidualBiasFusePass::ApplyImpl(ir::Graph *graph) const {
GET_IR_NODE_FROM_SUBGRAPH(layer_norm_mean, layer_norm_mean, fused_pattern);
GET_IR_NODE_FROM_SUBGRAPH(
layer_norm_variance, layer_norm_variance, fused_pattern);
// We can not accept that two or more layer_norm is connected to
// elementwise1_out. This will lead to two or more PrelnResidualBias
// patterns is found near elementwise1_out, and these patterns will interact
// on each other, so we make below check to ensure only one
// PrelnResidualBias pattern is delalted with.
for (auto op : elementwise1_out->inputs) {
if (op->Name() == "preln_residual_bias") return;
}
if (!IsCompat(subgraph, graph)) {
LOG(WARNING) << "preln_residual_bias pass in op compat failed.";
return;
}
std::unordered_set<const Node *> del_node_set;
// Create an PrelnResidualBias op node
OpDesc new_desc;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册