summaryrefslogtreecommitdiff
path: root/nn/runtime/test/specs/V1_3/div_int32.mod.py
diff options
context:
space:
mode:
authorXusong Wang <xusongw@google.com>2020-03-30 10:07:10 -0700
committerXusong Wang <xusongw@google.com>2020-03-30 15:27:57 -0700
commit139e82ccf51f563944548c786157b10d7409ba5b (patch)
treedfa9490ebac08087b9aa78d4ce3f6d391f99438f /nn/runtime/test/specs/V1_3/div_int32.mod.py
parentbc3b1e4bab6f55665ab0410b8e3d915c0025b5d9 (diff)
downloadml-139e82ccf51f563944548c786157b10d7409ba5b.tar.gz
Add tests of DIV by zero.
Added tests of DIV by zero. The tests exercise DIV by zero of all supported data types in CTS/VTS and only expect runtime/drivers to not crash. Updated the reference implementation of INT32 DIV. Before this CL, the reference implementation will crash with floating point exception. This CL forces INT DIV by zero to return 0. Fixes: 151151830 Test: NNT_static Change-Id: I49f39c6ed41bab5d368498b37909de6a1c808d1e
Diffstat (limited to 'nn/runtime/test/specs/V1_3/div_int32.mod.py')
-rw-r--r--nn/runtime/test/specs/V1_3/div_int32.mod.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/nn/runtime/test/specs/V1_3/div_int32.mod.py b/nn/runtime/test/specs/V1_3/div_int32.mod.py
index d378f5973..d3642f3e0 100644
--- a/nn/runtime/test/specs/V1_3/div_int32.mod.py
+++ b/nn/runtime/test/specs/V1_3/div_int32.mod.py
@@ -74,3 +74,16 @@ Example({
-3, -5, -9, 9, 4, 3,
],
})
+
+
+# Test DIV by zero.
+# It is undefined behavior. The output is ignored and we only require the drivers to not crash.
+input0 = Input("input0", "TENSOR_INT32", "{1}")
+input1 = Input("input1", "TENSOR_INT32", "{1}")
+output = IgnoredOutput("output", "TENSOR_INT32", "{1}")
+model = Model("by_zero").Operation("DIV", input0, input1, 0).To(output)
+Example({
+ input0: [1],
+ input1: [0],
+ output: [0],
+})