Skip to content

Commit 4ee3f6d

Browse files
authored
[Pass] fix quant_dequant_fuse_pass when there is no dequant op before weight (#10093)
1 parent 151014e commit 4ee3f6d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lite/core/optimizer/mir/fusion/quant_dequant_op_fuser.cc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,25 @@ void QuantDequantLinearOpFuser::InsertNewNode(SSAGraph* graph,
708708
std::string op_type = op_info.Type();
709709
if (std::find(quant_op_types_.begin(), quant_op_types_.end(), op_type) !=
710710
quant_op_types_.end()) {
711-
op_info.SetAttr("enable_int8", true);
711+
bool enable_int8_cond = false;
712+
for (auto& inlink_node : quantized_node->inlinks) {
713+
enable_int8_cond = true;
714+
/* run int8 kernel run fp32 kernel
715+
data data
716+
/ /
717+
weight quant_op quant_op
718+
\ / /
719+
dequant_op dequant_op weight dequant_op
720+
\ / \ /
721+
conv conv
722+
*/
723+
if (inlink_node->IsArg() && inlink_node->arg()->is_weight &&
724+
inlink_node->inlinks.size() == 0) {
725+
enable_int8_cond = false;
726+
break;
727+
}
728+
}
729+
if (enable_int8_cond) op_info.SetAttr("enable_int8", true);
712730
}
713731
op_info.SetInputScale(input_var_name, scales);
714732
for (auto op_out_var_node : quantized_node->outlinks) {

0 commit comments

Comments
 (0)