From 3558f4a525eaf28aa508a62044526189551c9119 Mon Sep 17 00:00:00 2001 From: Andrzej Kotlowski Date: Tue, 15 Feb 2022 16:50:24 +0100 Subject: [PATCH] Remove first_quantization_pass FC property It turns out that first_quantization_pass FC property is not needed any longer --- .../nn/dnnl/dnnl_fully_connected-inl.h | 4 --- src/operator/subgraph/dnnl/dnnl_fc_property.h | 3 --- src/operator/subgraph/dnnl/dnnl_fc_sum_fuse.h | 25 +++++++++---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/operator/nn/dnnl/dnnl_fully_connected-inl.h b/src/operator/nn/dnnl/dnnl_fully_connected-inl.h index 4196b1581e21..be46666bac67 100644 --- a/src/operator/nn/dnnl/dnnl_fully_connected-inl.h +++ b/src/operator/nn/dnnl/dnnl_fully_connected-inl.h @@ -44,7 +44,6 @@ struct DNNLFCParam : public dmlc::Parameter { bool enable_float_output; bool with_eltwise; bool with_sum; - bool first_quantization_pass; // True for operator created during first quantization pass dmlc::optional min_calib_range; // min float value calculated from calibration dataset dmlc::optional max_calib_range; // max float value calculated from calibration dataset dmlc::optional channel_wise_quantize; @@ -59,9 +58,6 @@ struct DNNLFCParam : public dmlc::Parameter { .set_default(false) .describe("Whether there's a post with_eltwise after FullyConnected operator"); DMLC_DECLARE_FIELD(with_sum).set_default(false).describe("Add post sum"); - DMLC_DECLARE_FIELD(first_quantization_pass) - .set_default(false) - .describe("True for first quantization pass"); DMLC_DECLARE_FIELD(min_calib_range) .set_default(dmlc::optional()) .describe( diff --git a/src/operator/subgraph/dnnl/dnnl_fc_property.h b/src/operator/subgraph/dnnl/dnnl_fc_property.h index b22c5ef3ce70..64fd507e743b 100644 --- a/src/operator/subgraph/dnnl/dnnl_fc_property.h +++ b/src/operator/subgraph/dnnl/dnnl_fc_property.h @@ -194,9 +194,6 @@ class SgDNNLFCProperty : public SubgraphProperty { auto& sub_name = node->op()->name; if (sub_name == "FullyConnected") { node_name << "fully_connected_"; - if (HasAttr("quantize") && GetAttr("quantize")) { - n->attrs.dict["first_quantization_pass"] = "True"; - } } else if (SupportDNNLFCEltwiseFusion(sub_name)) { node_name << "eltwise_"; n->attrs.dict["with_eltwise"] = "True"; diff --git a/src/operator/subgraph/dnnl/dnnl_fc_sum_fuse.h b/src/operator/subgraph/dnnl/dnnl_fc_sum_fuse.h index 4af89c9298f6..6cfce33621a1 100644 --- a/src/operator/subgraph/dnnl/dnnl_fc_sum_fuse.h +++ b/src/operator/subgraph/dnnl/dnnl_fc_sum_fuse.h @@ -71,18 +71,18 @@ class SgDNNLFCSumFuseSelector : public SubgraphSelectorV2 { bool Select(const BiDirectedNode& seed_node, const std::shared_ptr& node_attr) override { const auto n = seed_node.node; - if (n->op() == Op::Get("_sg_onednn_fully_connected") && SupportDNNLAttr(node_attr) && - (seed_node.outputs.size() == 1)) { - auto const& fc_param = nnvm::get(n->attrs.parsed); - if ((!quantized_ && !fc_param.dnnl_param.first_quantization_pass) || - (fc_param.dnnl_param.quantized && !fc_param.dnnl_param.with_eltwise)) { - // Start subgraph when fusing for floats (quantized_ is false for DNNL backend) or - // when FC is already quantized (second pass for DNNL_QUANTIZE) but not already fuzed - // with elemwise operator. - status_ = kStart; - matched_list_.clear(); - matched_list_.push_back(&seed_node); - return true; + if (n->op() == Op::Get("_sg_onednn_fully_connected")) { + if (SupportDNNLAttr(node_attr) && (seed_node.outputs.size() == 1)) { + auto const& fc_param = nnvm::get(n->attrs.parsed); + if ((!quantized_) || (fc_param.dnnl_param.quantized && !fc_param.dnnl_param.with_eltwise)) { + // Start subgraph when fusing for floats (quantized_ is false for ONEDNN backend) or + // when FC is already quantized (second pass for ONEDNN_QUANTIZE) but not already fuzed + // with elemwise operator. + status_ = kStart; + matched_list_.clear(); + matched_list_.push_back(&seed_node); + return true; + } } } return false; @@ -203,7 +203,6 @@ class SgDNNLFCSumFuseProperty : public SubgraphProperty { fc_node->attrs.subgraphs.clear(); fc_node->attrs.subgraphs.emplace_back(std::make_shared(new_sym)); fc_node->attrs.dict["with_sum"] = "True"; - fc_node->attrs.dict.erase("first_quantization_pass"); // Removed as not needed any longer fc_node->op()->attr_parser(&(fc_node->attrs)); } return fc_node;