Enable Reduce min/max quantization for post training quantization.

Also, enable zip tests
Fixes #39601

PiperOrigin-RevId: 321399245
Change-Id: Ieae5cbf7b916241a4a15635e3a467e630fdf7595
This commit is contained in:
Karim Nosir 2020-07-15 11:15:12 -07:00 committed by TensorFlower Gardener
parent 0dcb8001ad
commit 9edc5097b9
3 changed files with 15 additions and 3 deletions

View File

@ -516,7 +516,8 @@ TfLiteStatus EvalLogic(TfLiteContext* context, TfLiteNode* node,
ResizeTempAxis(context, op_context, resolved_axis)); ResizeTempAxis(context, op_context, resolved_axis));
TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, op_context)); TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, op_context));
} }
if (op_context->input->type == kTfLiteUInt8) { if (op_context->input->type == kTfLiteUInt8 ||
op_context->input->type == kTfLiteInt8) {
TF_LITE_ENSURE_EQ(context, op_context->input->params.scale, TF_LITE_ENSURE_EQ(context, op_context->input->params.scale,
op_context->output->params.scale); op_context->output->params.scale);
TF_LITE_ENSURE_EQ(context, op_context->input->params.zero_point, TF_LITE_ENSURE_EQ(context, op_context->input->params.zero_point,

View File

@ -249,13 +249,17 @@ def make_reduce_prod_tests(options):
@register_make_test_function() @register_make_test_function()
def make_reduce_max_tests(options): def make_reduce_max_tests(options):
"""Make a set of tests to do max.""" """Make a set of tests to do max."""
return make_reduce_tests(tf.reduce_max)(options) return make_reduce_tests(
tf.reduce_max, allow_fully_quantize=True, min_value=-1, max_value=1)(
options)
@register_make_test_function() @register_make_test_function()
def make_reduce_min_tests(options): def make_reduce_min_tests(options):
"""Make a set of tests to do min.""" """Make a set of tests to do min."""
return make_reduce_tests(tf.reduce_min)(options) return make_reduce_tests(
tf.reduce_min, allow_fully_quantize=True, min_value=-1, max_value=1)(
options)
@register_make_test_function() @register_make_test_function()

View File

@ -975,6 +975,13 @@ OperatorProperty GetOperatorProperty(const ModelT* model, int subgraph_index,
property.restrict_same_input_output_scale = true; property.restrict_same_input_output_scale = true;
property.version = 2; property.version = 2;
break; break;
case BuiltinOperator_REDUCE_MAX:
case BuiltinOperator_REDUCE_MIN:
property.inputs = {{0, {}}};
property.outputs = {{0, {}}};
property.restrict_same_input_output_scale = true;
property.version = 2;
break;
default: default:
// No quantized implementation exists for this operation. // No quantized implementation exists for this operation.
property.quantizable = false; property.quantizable = false;