summaryrefslogtreecommitdiff
path: root/nn/runtime/test/specs/V1_3
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-03-20 12:55:39 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-20 12:55:39 +0000
commit005742de054649ed20b85021c5cc5228dd9b067e (patch)
treee4e63cfcf72785ba34da07be4a9dad126d357ace /nn/runtime/test/specs/V1_3
parent7720040c82375804419366c8c00f5a540b6ddab8 (diff)
parentc0f74da9faad6671bda8d947f8122bfd5141220f (diff)
downloadml-005742de054649ed20b85021c5cc5228dd9b067e.tar.gz
Merge changes I97e66261,I8d1eccd3 into rvc-dev
* changes: Document and test L2_NORMALIZATION with input of all zeros. Add tests for corner cases of quant8 l2 norm.
Diffstat (limited to 'nn/runtime/test/specs/V1_3')
-rw-r--r--nn/runtime/test/specs/V1_3/l2_normalization_zeros.mod.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/nn/runtime/test/specs/V1_3/l2_normalization_zeros.mod.py b/nn/runtime/test/specs/V1_3/l2_normalization_zeros.mod.py
new file mode 100644
index 000000000..6af710795
--- /dev/null
+++ b/nn/runtime/test/specs/V1_3/l2_normalization_zeros.mod.py
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2020 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.
+#
+
+# Test L2_NORMALIZATION with inputs of all zeros.
+i1 = Input("op1", "TENSOR_FLOAT32", "{2}") # input 0
+o1 = Output("op2", "TENSOR_FLOAT32", "{2}") # output 0
+axis = Int32Scalar("axis", -1) # last axis
+
+quant8 = DataTypeConverter().Identify({
+ i1: ("TENSOR_QUANT8_ASYMM", 0.1, 32),
+ o1: ("TENSOR_QUANT8_ASYMM", 1.0 / 128, 128)
+})
+
+quant8_signed = DataTypeConverter().Identify({
+ i1: ("TENSOR_QUANT8_ASYMM_SIGNED", 0.1, -96),
+ o1: ("TENSOR_QUANT8_ASYMM_SIGNED", 1.0 / 128, 0)
+})
+
+Model().IntroducedIn("V1_2").Operation("L2_NORMALIZATION", i1, axis).To(o1)
+Example({
+ i1: [0, 0],
+ o1: [0, 0]
+}).AddVariations("relaxed", "float16", quant8, quant8_signed)
+
+# TENSOR_QUANT8_ASYMM_SIGNED is a new data type in V1_3.
+Example.SetVersion("V1_3",
+ "l2_normalization_zeros_quant8_signed",
+ "l2_normalization_zeros_quant8_signed_all_inputs_as_internal")