From e6ffdb7c6c208187ec63dff375502f01054887d6 Mon Sep 17 00:00:00 2001 From: Nat Jeffries Date: Mon, 9 Nov 2020 15:23:30 -0800 Subject: [PATCH] Fix quantize kernel to prepare quantization for int16->int32 requant. Previously the kernel would run but quantized multiplier and shift were not generated properly during Prepare. PiperOrigin-RevId: 341496881 Change-Id: Id9d2534b09c91b8353e4364bfdb1af5ef3a81f82 --- tensorflow/lite/micro/kernels/quantize.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tensorflow/lite/micro/kernels/quantize.cc b/tensorflow/lite/micro/kernels/quantize.cc index f6d8c927949..8b9bf7e5fb1 100644 --- a/tensorflow/lite/micro/kernels/quantize.cc +++ b/tensorflow/lite/micro/kernels/quantize.cc @@ -70,9 +70,10 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { output->type == kTfLiteInt16 || output->type == kTfLiteInt32); - if (((input->type == kTfLiteInt16 || input->type == kTfLiteInt8) && - output->type == kTfLiteInt8) || - (input->type == kTfLiteInt16 && output->type == kTfLiteInt16)) { + if ((input->type == kTfLiteInt16 && output->type == kTfLiteInt8) || + (input->type == kTfLiteInt8 && output->type == kTfLiteInt8) || + (input->type == kTfLiteInt16 && output->type == kTfLiteInt16) || + (input->type == kTfLiteInt16 && output->type == kTfLiteInt32)) { double effective_scale = static_cast(input->params.scale) / static_cast(output->params.scale);