From 8cf2895fcce8fb47ef1b603f9784a34a72d5ae54 Mon Sep 17 00:00:00 2001 From: Suharsh Sivakumar Date: Tue, 16 Jun 2020 13:38:34 -0700 Subject: [PATCH] Add dynamic range test to op_tests A-B. PiperOrigin-RevId: 316748721 Change-Id: I2e803777a160197f3b7a6026c5e94ce11f47ab92 --- tensorflow/lite/testing/op_tests/add_n.py | 9 ++++ .../lite/testing/op_tests/arg_min_max.py | 3 +- .../testing/op_tests/batch_to_space_nd.py | 4 ++ tensorflow/lite/testing/op_tests/binary_op.py | 54 +++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/tensorflow/lite/testing/op_tests/add_n.py b/tensorflow/lite/testing/op_tests/add_n.py index 2385bd89600..bef0a0632b9 100644 --- a/tensorflow/lite/testing/op_tests/add_n.py +++ b/tensorflow/lite/testing/op_tests/add_n.py @@ -32,16 +32,25 @@ def make_add_n_tests(options): "dtype": [tf.float32, tf.int32], "input_shape": [[2, 5, 3, 1]], "num_inputs": [2, 3, 4, 5], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32, tf.int32], "input_shape": [[5]], "num_inputs": [2, 3, 4, 5], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32, tf.int32], "input_shape": [[]], "num_inputs": [2, 3, 4, 5], + "dynamic_range_quantize": [False], + }, + { + "dtype": [tf.float32], + "input_shape": [[]], + "num_inputs": [2, 3, 4, 5], + "dynamic_range_quantize": [True], }, ] diff --git a/tensorflow/lite/testing/op_tests/arg_min_max.py b/tensorflow/lite/testing/op_tests/arg_min_max.py index e693ce6f44a..ec0013225e0 100644 --- a/tensorflow/lite/testing/op_tests/arg_min_max.py +++ b/tensorflow/lite/testing/op_tests/arg_min_max.py @@ -34,6 +34,7 @@ def make_arg_min_max_tests(options): "input_shape": [[], [1, 1, 1, 3], [2, 3, 4, 5], [2, 3, 3], [5, 5], [10]], "output_type": [tf.int32, tf.int64], "is_arg_max": [True], + "dynamic_range_quantize": [False, True], }] def build_graph(parameters): @@ -62,4 +63,4 @@ def make_arg_min_max_tests(options): test_parameters, build_graph, build_inputs, - expected_tf_failures=4) + expected_tf_failures=8) diff --git a/tensorflow/lite/testing/op_tests/batch_to_space_nd.py b/tensorflow/lite/testing/op_tests/batch_to_space_nd.py index e3f05697b0b..2180bfa5b10 100644 --- a/tensorflow/lite/testing/op_tests/batch_to_space_nd.py +++ b/tensorflow/lite/testing/op_tests/batch_to_space_nd.py @@ -36,6 +36,7 @@ def make_batch_to_space_nd_tests(options): "crops": [[[0, 0], [0, 0]], [[1, 1], [1, 1]]], "constant_block_shape": [True, False], "constant_crops": [True, False], + "dynamic_range_quantize": [False], }, # Single batch (no-op) { @@ -45,6 +46,7 @@ def make_batch_to_space_nd_tests(options): "crops": [[[0, 0], [0, 0]], [[1, 1], [1, 1]]], "constant_block_shape": [True], "constant_crops": [True], + "dynamic_range_quantize": [True, False], }, # 3D use case. { @@ -54,6 +56,7 @@ def make_batch_to_space_nd_tests(options): "crops": [[[0, 0]], [[1, 1]]], "constant_block_shape": [True], "constant_crops": [True], + "dynamic_range_quantize": [True, False], }, ] @@ -66,6 +69,7 @@ def make_batch_to_space_nd_tests(options): "crops": [[[0, 0], [0, 0], [0, 0]]], "constant_block_shape": [True, False], "constant_crops": [True, False], + "dynamic_range_quantize": [False], }] def build_graph(parameters): diff --git a/tensorflow/lite/testing/op_tests/binary_op.py b/tensorflow/lite/testing/op_tests/binary_op.py index 9d0c85e35aa..17ed2f3522d 100644 --- a/tensorflow/lite/testing/op_tests/binary_op.py +++ b/tensorflow/lite/testing/op_tests/binary_op.py @@ -41,6 +41,7 @@ def make_binary_op_tests(options, "input_shape_2": [[1, 3, 4, 3]], "activation": [True], "fully_quantize": [False], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -48,6 +49,7 @@ def make_binary_op_tests(options, "input_shape_2": [[5]], "activation": [False, True], "fully_quantize": [False], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32, tf.int32, tf.int64], @@ -55,6 +57,7 @@ def make_binary_op_tests(options, "input_shape_2": [[3]], "activation": [True, False], "fully_quantize": [False], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32, tf.int32], @@ -62,6 +65,7 @@ def make_binary_op_tests(options, "input_shape_2": [[1, 3, 4, 3]], "activation": [True, False], "fully_quantize": [False], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -69,6 +73,7 @@ def make_binary_op_tests(options, "input_shape_2": [[]], "activation": [False], "fully_quantize": [False], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -76,6 +81,7 @@ def make_binary_op_tests(options, "input_shape_2": [[1]], "activation": [False], "fully_quantize": [False], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -83,6 +89,7 @@ def make_binary_op_tests(options, "input_shape_2": [[1, 3, 4, 3]], "activation": [False], "fully_quantize": [True], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -90,6 +97,7 @@ def make_binary_op_tests(options, "input_shape_2": [[5]], "activation": [False], "fully_quantize": [True], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -97,6 +105,7 @@ def make_binary_op_tests(options, "input_shape_2": [[3]], "activation": [False], "fully_quantize": [True], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -104,6 +113,7 @@ def make_binary_op_tests(options, "input_shape_2": [[1, 3, 4, 3]], "activation": [False], "fully_quantize": [True], + "dynamic_range_quantize": [False], }, { "dtype": [tf.float32], @@ -111,6 +121,47 @@ def make_binary_op_tests(options, "input_shape_2": [[]], "activation": [False], "fully_quantize": [True], + "dynamic_range_quantize": [False], + }, + { + "dtype": [tf.float32], + "input_shape_1": [[1, 3, 4, 3]], + "input_shape_2": [[1, 3, 4, 3]], + "activation": [False], + "fully_quantize": [False], + "dynamic_range_quantize": [True], + }, + { + "dtype": [tf.float32], + "input_shape_1": [[5]], + "input_shape_2": [[5]], + "activation": [False], + "fully_quantize": [False], + "dynamic_range_quantize": [True], + }, + { + "dtype": [tf.float32], + "input_shape_1": [[1, 3, 4, 3]], + "input_shape_2": [[3]], + "activation": [False], + "fully_quantize": [False], + "dynamic_range_quantize": [True], + }, + { + "dtype": [tf.float32], + "input_shape_1": [[3]], + "input_shape_2": [[1, 3, 4, 3]], + "activation": [False], + "fully_quantize": [False], + "dynamic_range_quantize": [True], + }, + { + "dtype": [tf.float32], + "input_shape_1": [[]], + "input_shape_2": [[]], + "activation": [False], + "fully_quantize": [False], + "dynamic_range_quantize": [True], }, ] @@ -123,6 +174,7 @@ def make_binary_op_tests(options, "input_shape_2": [[7]], "activation": [False], "fully_quantize": [False], + "dynamic_range_quantize": [False], }, ] @@ -204,6 +256,7 @@ def make_div_tests(options): "input_shape_2": [[3]], "activation": [False], "fully_quantize": [False], + "dynamic_range_quantize": [False, True], }, ] make_binary_op_tests( @@ -220,6 +273,7 @@ def make_sub_tests(options): "input_shape_2": [[3]], "activation": [False], "fully_quantize": [False], + "dynamic_range_quantize": [False, True], }, ] make_binary_op_tests(