Browse Source

!7742 fix post training quant

Merge pull request !7742 from xutianchun/ptf
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
5c2aa6e49e
4 changed files with 8 additions and 3 deletions
  1. +3
    -0
      mindspore/lite/tools/converter/legacy_optimizer/graph/trans_format_insert_pass.cc
  2. +3
    -1
      mindspore/lite/tools/converter/quantizer/post_training_quantizer.cc
  3. +1
    -1
      mindspore/lite/tools/converter/quantizer/post_training_quantizer.h
  4. +1
    -1
      mindspore/lite/tools/converter/quantizer/quantize_util.cc

+ 3
- 0
mindspore/lite/tools/converter/legacy_optimizer/graph/trans_format_insert_pass.cc View File

@@ -92,6 +92,9 @@ bool TransOpInsertPass::CanFusion(schema::MetaGraphT *graph, const std::unique_p
return has_trans_count >= half_count;
}
}
if (GetCNodeTType(*node) == schema::PrimitiveType_Split) {
return has_trans_count >= half_count;
}
can_fusion = has_trans_count > half_count;
return can_fusion;
}


+ 3
- 1
mindspore/lite/tools/converter/quantizer/post_training_quantizer.cc View File

@@ -798,6 +798,7 @@ STATUS PostTrainingQuantizer::QuantNode() {
primitive_c->SetQuantType(schema::QuantType_PostTraining);
continue;
} else if (op_type != PrimitiveType_Conv2D && op_type != PrimitiveType_DepthwiseConv2D &&
op_type != PrimitiveType_DeConv2D && op_type != PrimitiveType_DeDepthwiseConv2D &&
op_type != PrimitiveType_FullConnection) {
for (size_t i = 1; i < cnode->inputs().size(); i++) {
auto input_node = cnode->input(i);
@@ -847,7 +848,8 @@ STATUS PostTrainingQuantizer::QuantNode() {
// do weight quant
auto weight = cnode->input(2);
bool perchannel = per_channel_;
if (op_type == PrimitiveType_FullConnection) {
if (op_type == PrimitiveType_FullConnection || op_type == PrimitiveType_DeConv2D ||
op_type == PrimitiveType_DeDepthwiseConv2D) {
perchannel = false;
}
DoWeightQuant(weight, primitive_c, perchannel);


+ 1
- 1
mindspore/lite/tools/converter/quantizer/post_training_quantizer.h View File

@@ -65,7 +65,7 @@ class PostTrainingQuantizer : public Quantizer {
int quant_min{INT8_MIN};

private:
bool per_channel_;
bool per_channel_{true};

TypeId target_type_{kNumberTypeInt8};



+ 1
- 1
mindspore/lite/tools/converter/quantizer/quantize_util.cc View File

@@ -108,7 +108,7 @@ bool QuantStrategy::CanOpPostQuantized(AnfNodePtr &node) const {
schema::PrimitiveType_DeDepthwiseConv2D,
schema::PrimitiveType_DeConv2D,
schema::PrimitiveType_Activation,
schema::PrimitiveType_TupleGetItem,
schema::PrimitiveType_Eltwise,
};
bool contain = IsContain(int8OpList, type);
if (!contain) {


Loading…
Cancel
Save