From 165c8c5dbd8ac183bd322266798321adb4886f45 Mon Sep 17 00:00:00 2001 From: Elena Zhelezina Date: Thu, 4 Jun 2020 11:05:48 +0100 Subject: [PATCH] Addressed reviewer's comments. Change-Id: If8022418adcc6b6a93354625476f32155dd53d36 --- tensorflow/lite/kernels/pad.cc | 40 +++++----------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/tensorflow/lite/kernels/pad.cc b/tensorflow/lite/kernels/pad.cc index 4a4668c9634..4c4caeea853 100644 --- a/tensorflow/lite/kernels/pad.cc +++ b/tensorflow/lite/kernels/pad.cc @@ -120,8 +120,8 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { } template -TfLiteStatus EvalSignedInt(TfLiteContext* context, const PadContext& op_context, - const tflite::PadParams& op_params) { +TfLiteStatus EvalInt(TfLiteContext* context, const PadContext& op_context, + const tflite::PadParams& op_params) { integer_type pad_value; if (op_context.constant_values == nullptr) { // Quantized Pad requires that 0 is represented in the quantized @@ -211,43 +211,13 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { } } break; case kTfLiteUInt8: { - uint8_t pad_value; - if (op_context.constant_values == nullptr) { - // Quantized Pad requires that 0 is represented in the quantized - // range. - TF_LITE_ENSURE(context, op_context.output->params.zero_point >= - std::numeric_limits::min()); - TF_LITE_ENSURE(context, op_context.output->params.zero_point <= - std::numeric_limits::max()); - pad_value = static_cast(op_context.output->params.zero_point); - } else { - // Quantized Pad requires that 'constant_values' is represented in the - // same quantized range as the input and output tensors. - TF_LITE_ENSURE_EQ(context, op_context.output->params.zero_point, - op_context.constant_values->params.zero_point); - TF_LITE_ENSURE_EQ(context, op_context.output->params.scale, - op_context.constant_values->params.scale); - pad_value = *GetTensorData(op_context.constant_values); - } - if (kernel_type == kReference) { - if (op_context.resizing_category == ResizingCategory::kImageStyle) { - TF_LITE_PAD(reference_ops, PadImageStyle, uint8_t, pad_value); - } else { - TF_LITE_PAD(reference_ops, Pad, uint8_t, pad_value); - } - } else if (kernel_type == kGenericOptimized) { - if (op_context.resizing_category == ResizingCategory::kImageStyle) { - TF_LITE_PAD(optimized_ops, PadImageStyle, uint8_t, pad_value); - } else { - TF_LITE_PAD(optimized_ops, Pad, uint8_t, pad_value); - } - } + EvalInt(context, op_context, op_params); } break; case kTfLiteInt8: { - EvalSignedInt(context, op_context, op_params); + EvalInt(context, op_context, op_params); } break; case kTfLiteInt16: { - EvalSignedInt(context, op_context, op_params); + EvalInt(context, op_context, op_params); } break; case kTfLiteInt32: { int32_t pad_value =