diff options
author | Lev Proleev <levp@google.com> | 2019-12-19 15:18:50 +0000 |
---|---|---|
committer | Lev Proleev <levp@google.com> | 2020-01-03 16:01:32 +0000 |
commit | f40dc3a495a069d70d95187c7e2eb68e22a514bd (patch) | |
tree | 5ce61595f8fad9ead7741652c2b26f1f8ed63e5d /nn/runtime/test/specs/V1_3/not_equal_quant8_signed.mod.py | |
parent | 21d5907e55f6ed8a3e08c240efb9cf5d4a644fd8 (diff) | |
download | ml-f40dc3a495a069d70d95187c7e2eb68e22a514bd.tar.gz |
Add quant8 signed generated tests
The tests are written semi-automatically by joining all of the 1.0-1.2
tests with TENSOR_QUANT8_ASYMM operands and converting them to
TENSOR_QUANT8_ASYMM_SIGNED.
Also:
* Fix implementation of CONCATENATION op for zero-sized tensors
* Add support for TENSOR_QUANT8_ASYMM_SIGNED in test generator
Bug: 136735770
Test: NNTest_static and VtsHalNeuralnetworksV1_3TargetTest
Change-Id: I250dbe85684aa594892494eb53e6312c1cacb6f3
Diffstat (limited to 'nn/runtime/test/specs/V1_3/not_equal_quant8_signed.mod.py')
-rw-r--r-- | nn/runtime/test/specs/V1_3/not_equal_quant8_signed.mod.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/nn/runtime/test/specs/V1_3/not_equal_quant8_signed.mod.py b/nn/runtime/test/specs/V1_3/not_equal_quant8_signed.mod.py new file mode 100644 index 000000000..285c41d09 --- /dev/null +++ b/nn/runtime/test/specs/V1_3/not_equal_quant8_signed.mod.py @@ -0,0 +1,62 @@ +# +# Copyright (C) 2019 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +def test(name, input0, input1, output0, input0_data, input1_data, output_data): + model = Model().Operation("NOT_EQUAL", input0, input1).To(output0) + example = Example({ + input0: input0_data, + input1: input1_data, + output0: output_data, + }, model=model, name=name) + +test( + name="quantized_different_scale", + input0=Input("input0", ("TENSOR_QUANT8_ASYMM_SIGNED", [3], 1.0, 0)), + input1=Input("input1", ("TENSOR_QUANT8_ASYMM_SIGNED", [1], 2.0, 0)), + output0=Output("output0", "TENSOR_BOOL8", "{3}"), + input0_data=[1, 2, 3], # effectively 1, 2, 3 + input1_data=[1], # effectively 2 + output_data=[True, False, True], +) + +test( + name="quantized_different_zero_point", + input0=Input("input0", ("TENSOR_QUANT8_ASYMM_SIGNED", [3], 1.0, 0)), + input1=Input("input1", ("TENSOR_QUANT8_ASYMM_SIGNED", [1], 1.0, 1)), + output0=Output("output0", "TENSOR_BOOL8", "{3}"), + input0_data=[1, 2, 3], # effectively 1, 2, 3 + input1_data=[3], # effectively 2 + output_data=[True, False, True], +) + +test( + name="quantized_overflow_second_input_if_requantized", + input0=Input("input0", ("TENSOR_QUANT8_ASYMM_SIGNED", [1], 1.64771, -97)), + input1=Input("input1", ("TENSOR_QUANT8_ASYMM_SIGNED", [1], 1.49725, 112)), + output0=Output("output0", "TENSOR_BOOL8", "{1}"), + input0_data=[-128], + input1_data=[72], + output_data=[True], +) + +test( + name="quantized_overflow_first_input_if_requantized", + input0=Input("input0", ("TENSOR_QUANT8_ASYMM_SIGNED", [1], 1.49725, 112)), + input1=Input("input1", ("TENSOR_QUANT8_ASYMM_SIGNED", [1], 1.64771, -97)), + output0=Output("output0", "TENSOR_BOOL8", "{1}"), + input0_data=[72], + input1_data=[-128], + output_data=[True], +) |