From a6e10b6e09fa1daf9e6314b3c858925482c81e37 Mon Sep 17 00:00:00 2001 From: Karim Nosir Date: Thu, 9 Apr 2020 11:47:16 -0700 Subject: [PATCH] Add more details for quantization failure error message PiperOrigin-RevId: 305727582 Change-Id: I360dd94e03ae867972db502879d043c7e801ac60 --- .../lite/tools/optimize/quantize_model.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tensorflow/lite/tools/optimize/quantize_model.cc b/tensorflow/lite/tools/optimize/quantize_model.cc index 0f05e9f80bf..6c6ba10d60c 100644 --- a/tensorflow/lite/tools/optimize/quantize_model.cc +++ b/tensorflow/lite/tools/optimize/quantize_model.cc @@ -1001,9 +1001,20 @@ TfLiteStatus FillQuantizationParams( // Dynamic tensor. } else if (!utils::HasMinMax(tensor) && !utils::HasBuffer(model, subgraph, tensor_idx)) { - TF_LITE_REPORT_ERROR(error_reporter, - "Max and min for dynamic tensors should be" - " recorded during calibration"); + TF_LITE_REPORT_ERROR( + error_reporter, + "Max and min for dynamic tensors should be" + " recorded during calibration: Failed for tensor %s\n", + tensor->name.c_str()); + if (tensor->quantization == nullptr) { + TF_LITE_REPORT_ERROR(error_reporter, + "No quantization params for tensor %s", + tensor->name.c_str()); + } else if (tensor->quantization->min.empty() || + tensor->quantization->max.empty()) { + TF_LITE_REPORT_ERROR(error_reporter, "Empty min/max for tensor %s", + tensor->name.c_str()); + } return kTfLiteError; }