You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by bg...@apache.org on 2022/03/04 09:15:18 UTC
[incubator-mxnet] branch master updated: Remove first_quantization_pass FC property (#20908)
This is an automated email from the ASF dual-hosted git repository.
bgawrych pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 6c2b3dc Remove first_quantization_pass FC property (#20908)
6c2b3dc is described below
commit 6c2b3dc41ae0be1ae583a931838058388a37ec1c
Author: Andrzej Kotłowski <An...@intel.com>
AuthorDate: Fri Mar 4 10:13:50 2022 +0100
Remove first_quantization_pass FC property (#20908)
remove first_quantization_pass attribute from subgraph FC as it is not needed any longer
---
src/operator/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 4196b15..be46666 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<DNNLFCParam> {
bool enable_float_output;
bool with_eltwise;
bool with_sum;
- bool first_quantization_pass; // True for operator created during first quantization pass
dmlc::optional<float> min_calib_range; // min float value calculated from calibration dataset
dmlc::optional<float> max_calib_range; // max float value calculated from calibration dataset
dmlc::optional<bool> channel_wise_quantize;
@@ -59,9 +58,6 @@ struct DNNLFCParam : public dmlc::Parameter<DNNLFCParam> {
.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<float>())
.describe(
diff --git a/src/operator/subgraph/dnnl/dnnl_fc_property.h b/src/operator/subgraph/dnnl/dnnl_fc_property.h
index b22c5ef..64fd507 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<bool>("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 4af89c9..6cfce33 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<NodeAttr>& 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<DNNLFCFullParam>(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<DNNLFCFullParam>(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<nnvm::Symbol>(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;