Modify op version in optimize only if convertor version < quantized version.
PiperOrigin-RevId: 311216743
Change-Id: Iaac04750d0d302e9bba11b223c2885d6a36d74b3
diff --git a/tensorflow/lite/tools/optimize/model_utils.cc b/tensorflow/lite/tools/optimize/model_utils.cc
index 26dcff2..ae868cf 100644
--- a/tensorflow/lite/tools/optimize/model_utils.cc
+++ b/tensorflow/lite/tools/optimize/model_utils.cc
@@ -134,8 +134,10 @@
OperatorCodeT* op_code = model->operator_codes[op->opcode_index].get();
operator_property::OperatorProperty property =
operator_property::GetOperatorProperty(model, subgraph_idx, op_idx);
- if (property.quantizable) {
- // Only update the versions of quantizable operations.
+ if (property.quantizable && op_code->version < property.version) {
+ // Only update the versions of quantizable operations if the original
+ // version is lesser than minimum quantized one mentioned by
+ // OperatorProperty.
op_code->version = property.version;
}
}