Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Remove first_quantization_pass FC property
Browse files Browse the repository at this point in the history
It turns out that first_quantization_pass FC property is not needed
any longer
  • Loading branch information
anko-intel committed Mar 3, 2022
1 parent 93aa9e3 commit 61a88b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
4 changes: 0 additions & 4 deletions src/operator/nn/dnnl/dnnl_fully_connected-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions src/operator/subgraph/dnnl/dnnl_fc_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
25 changes: 12 additions & 13 deletions src/operator/subgraph/dnnl/dnnl_fc_sum_fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 61a88b0

Please sign in to comment.