From e23d46c2340648b216b78e611dbd18dd2b3f2a44 Mon Sep 17 00:00:00 2001 From: Nat Jeffries Date: Wed, 15 Jan 2020 17:01:18 -0800 Subject: [PATCH] Ensure quantized dimension is 0 for conv and 3 for depthwise_conv as specified in https://www.tensorflow.org/lite/performance/quantization_spec PiperOrigin-RevId: 289966980 Change-Id: I2487e120e784aefd0d879be0616592ca0ecc45a6 --- tensorflow/lite/micro/kernels/conv.cc | 1 + tensorflow/lite/micro/kernels/depthwise_conv.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/tensorflow/lite/micro/kernels/conv.cc b/tensorflow/lite/micro/kernels/conv.cc index ac5c33826b2..c3bccbf6be4 100644 --- a/tensorflow/lite/micro/kernels/conv.cc +++ b/tensorflow/lite/micro/kernels/conv.cc @@ -232,6 +232,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, affine_quantization->zero_point); // Conv is quantized along dimension 0: // https://www.tensorflow.org/lite/performance/quantization_spec + TF_LITE_ENSURE_EQ(context, affine_quantization->quantized_dimension, 0); TF_LITE_ENSURE_EQ(context, filter->dims->data[0], affine_quantization->scale->size); TF_LITE_ENSURE_EQ(context, filter->dims->data[0], diff --git a/tensorflow/lite/micro/kernels/depthwise_conv.cc b/tensorflow/lite/micro/kernels/depthwise_conv.cc index c440990026d..3f6de5fca0d 100644 --- a/tensorflow/lite/micro/kernels/depthwise_conv.cc +++ b/tensorflow/lite/micro/kernels/depthwise_conv.cc @@ -224,6 +224,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, affine_quantization->zero_point); // Depthwise conv is quantized along dimension 3: // https://www.tensorflow.org/lite/performance/quantization_spec + TF_LITE_ENSURE_EQ(context, affine_quantization->quantized_dimension, 3); TF_LITE_ENSURE_EQ(context, filter->dims->data[3], affine_quantization->scale->size); TF_LITE_ENSURE_EQ(context, filter->dims->data[3],