From a0338d6505bfa40a8cca32d3610febd098082755 Mon Sep 17 00:00:00 2001 From: Elena Zhelezina Date: Tue, 10 Dec 2019 10:44:39 +0000 Subject: [PATCH] Addressed review comments. Change-Id: Ifefd7825025eedda29c1fc5baf7a14b5f0acae09 --- tensorflow/lite/tools/optimize/operator_property.cc | 1 - tensorflow/lite/tools/optimize/operator_property.h | 4 ---- tensorflow/lite/tools/optimize/quantize_model.cc | 6 ++---- tensorflow/lite/tools/optimize/quantize_model_test.cc | 2 -- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/tensorflow/lite/tools/optimize/operator_property.cc b/tensorflow/lite/tools/optimize/operator_property.cc index 30ae84ed53c..2eacd62725b 100644 --- a/tensorflow/lite/tools/optimize/operator_property.cc +++ b/tensorflow/lite/tools/optimize/operator_property.cc @@ -779,7 +779,6 @@ OperatorProperty GetOperatorProperty(const ModelT* model, int subgraph_index, property.arbitrary_inputs = true; property.outputs = {{0, {}}}; property.restrict_same_input_output_scale = true; - property.restrict_multiple_inputs_scale = true; property.version = 2; break; case BuiltinOperator_PAD: diff --git a/tensorflow/lite/tools/optimize/operator_property.h b/tensorflow/lite/tools/optimize/operator_property.h index a2b93da6ac2..5d37aa304e5 100644 --- a/tensorflow/lite/tools/optimize/operator_property.h +++ b/tensorflow/lite/tools/optimize/operator_property.h @@ -85,10 +85,6 @@ struct OperatorProperty { // Force output to reuse the same scale and zero point of input. bool restrict_same_input_output_scale = false; - // In the case of multiple inputs, requantize all inputs to have - // the same scale and zero point. - bool restrict_multiple_inputs_scale = false; - // Use same min of min and max of max for each group. // Incompatable with restrict_same_input_output_scale and restricted_value. // TODO(jianlijianli): make it compatible with other restrictions when there diff --git a/tensorflow/lite/tools/optimize/quantize_model.cc b/tensorflow/lite/tools/optimize/quantize_model.cc index 375c4b89462..30d9f961098 100644 --- a/tensorflow/lite/tools/optimize/quantize_model.cc +++ b/tensorflow/lite/tools/optimize/quantize_model.cc @@ -300,8 +300,7 @@ TfLiteStatus ApplyConstraints(ModelT* model, if (!property.quantizable) { continue; } - if ((!property.arbitrary_inputs && - !property.restrict_multiple_inputs_scale) || + if ((!property.arbitrary_inputs) || !property.restrict_same_input_output_scale) { continue; } @@ -385,8 +384,7 @@ bool ShouldRestrictSameInputOutputScale( operator_property::OperatorProperty property) { // Ops with multiple inputs (i.e. concat) gets restricted in ApplyConstraints. return (!property.arbitrary_inputs && - property.restrict_same_input_output_scale && - !property.restrict_multiple_inputs_scale); + property.restrict_same_input_output_scale); } bool IsSubgraphInput(SubGraphT* subgraph, int32_t index) { diff --git a/tensorflow/lite/tools/optimize/quantize_model_test.cc b/tensorflow/lite/tools/optimize/quantize_model_test.cc index b3eca76840d..85afbee8c42 100644 --- a/tensorflow/lite/tools/optimize/quantize_model_test.cc +++ b/tensorflow/lite/tools/optimize/quantize_model_test.cc @@ -1256,13 +1256,11 @@ class QuantizeUnpackTest : public QuantizeModelTest { }; TEST_F(QuantizeUnpackTest, VerifyUnpack) { - auto status = QuantizeModel(&builder_, &model_, &error_reporter_); ASSERT_EQ(kTfLiteOk, status); const auto subgraph = model_.subgraphs[0].get(); - auto op = subgraph->operators[1].get(); auto float_graph = readonly_model_->subgraphs()->Get(0);