Browse Source

fuse 2 quant_dtype_cast when srcAttr->srcT != dstAttr->dstT

tags/v1.1.0
cjh9368 5 years ago
parent
commit
2b1837afa5
1 changed files with 9 additions and 5 deletions
  1. +9
    -5
      mindspore/lite/tools/converter/legacy_optimizer/fusion/quant_cast_fusion_pass.cc

+ 9
- 5
mindspore/lite/tools/converter/legacy_optimizer/fusion/quant_cast_fusion_pass.cc View File

@@ -62,7 +62,7 @@ STATUS QuantCastFusionPass::DoFusion(MetaGraphT *graph, const std::string &patte
auto dstAttr = dstNode->primitive->value.AsQuantDTypeCast();
MS_ASSERT(srcAttr != nullptr);
MS_ASSERT(dstAttr != nullptr);
if (srcAttr->dstT != dstAttr->srcT || srcAttr->srcT != dstAttr->dstT) {
if (srcAttr->dstT != dstAttr->srcT) {
MS_LOG(ERROR) << "srcNode and dstNode can not been fused";
return RET_ERROR;
}
@@ -73,10 +73,14 @@ STATUS QuantCastFusionPass::DoFusion(MetaGraphT *graph, const std::string &patte
return status;
}

status = IsolateOneWayNode(graph, dstPath->nodeIdx);
if (status != RET_OK) {
MS_LOG(ERROR) << "IsolateOneWayNode failed, node: " << dstNode->name.c_str() << ", error: " << status;
return status;
if (srcAttr->srcT == dstAttr->dstT) {
status = IsolateOneWayNode(graph, dstPath->nodeIdx);
if (status != RET_OK) {
MS_LOG(ERROR) << "IsolateOneWayNode failed, node: " << dstNode->name.c_str() << ", error: " << status;
return status;
}
} else {
dstAttr->srcT = srcAttr->dstT;
}

return RET_OK;


Loading…
Cancel
Save