From 49938a4d5e83c78bf4e235075e1f943f616ac28b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Shubham=20Gupta/SNAP=20/SRI-Bangalore/Engineer/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 18 Dec 2018 06:36:55 +0530 Subject: [PATCH] Add gtests for transposeConv op to test Int32 dataype (#4037) This patch will add gtest to test TransposeConv op for int datatype Signed-off-by: shubham --- .../specs/Ex/transpose_conv_ex_int_1.mod.py | 24 +++++++++++++++++++ .../specs/Ex/transpose_conv_ex_int_2.mod.py | 25 ++++++++++++++++++++ .../specs/Ex/transpose_conv_ex_int_3.mod.py | 27 ++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_1.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_2.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_3.mod.py diff --git a/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_1.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_1.mod.py new file mode 100644 index 0000000..fb8eb72 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_1.mod.py @@ -0,0 +1,24 @@ +# model +model = Model() +i0 = Input("op_shape", "TENSOR_INT32", "{4}") +weights = Input("ker", "TENSOR_INT32", "{1, 3, 3, 1}") +i1 = Input("in", "TENSOR_INT32", "{1, 4, 4, 1}" ) +pad = Int32Scalar("pad_same", 1) +s_x = Int32Scalar("stride_x", 1) +s_y = Int32Scalar("stride_y", 1) +i2 = Output("op", "TENSOR_INT32", "{1, 4, 4, 1}") +model = model.Operation("TRANSPOSE_CONV_EX", i0, weights, i1, pad, s_x, s_y).To(i2) + +# Example 1. Input in operand 0, +input0 = {i0: # output shape + [1, 4, 4, 1], + i1: # input 0 + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], + weights: # input 1 + [1, 2, 3, 4, 5, 6, 7, 8, 9]} + +output0 = {i2: # output 0 + [29, 62, 83, 75, 99, 192, 237, 198, 207, 372, 417, 330, 263, 446, 485, 365]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_2.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_2.mod.py new file mode 100644 index 0000000..9bf4b11 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_2.mod.py @@ -0,0 +1,25 @@ +# model +model = Model() +i0 = Input("op_shape", "TENSOR_INT32", "{4}") +weights = Input("ker", "TENSOR_INT32", "{1, 3, 3, 1}") +i1 = Input("in", "TENSOR_INT32", "{1, 2, 2, 1}" ) +pad = Int32Scalar("pad_valid", 2) +s_x = Int32Scalar("stride_x", 2) +s_y = Int32Scalar("stride_y", 2) +i2 = Output("op", "TENSOR_INT32", "{1, 5, 5, 1}") +model = model.Operation("TRANSPOSE_CONV_EX", i0, weights, i1, pad, s_x, s_y).To(i2) + +# Example 1. Input in operand 0, +input0 = {i0: # output shape + [1, 5, 5, 1], + i1: # input 0 + [1, 2, 3, 4], + weights: # input 1 + [1, 2, 3, 4, 5, 6, 7, 8, 9]} + +output0 = {i2: # output 0 + [1, 2, 5, 4, 6, 4, 5, 14, 10, 12, 10, 14, 36, + 24, 30, 12, 15, 34, 20, 24, 21, 24, 55, 32, 36]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_3.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_3.mod.py new file mode 100644 index 0000000..e444809 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_int_3.mod.py @@ -0,0 +1,27 @@ +# model +model = Model() +i0 = Input("op_shape", "TENSOR_INT32", "{4}") +weights = Input("ker", "TENSOR_INT32", "{2, 3, 3, 1}") +i1 = Input("in", "TENSOR_INT32", "{1, 2, 2, 1}" ) +pad = Int32Scalar("pad_valid", 2) +s_x = Int32Scalar("stride_x", 2) +s_y = Int32Scalar("stride_y", 2) +i2 = Output("op", "TENSOR_INT32", "{1, 5, 5, 2}") +model = model.Operation("TRANSPOSE_CONV_EX", i0, weights, i1, pad, s_x, s_y).To(i2) + +# Example 1. Input in operand 0, +input0 = {i0: # output shape + [1, 5, 5, 2], + i1: # input 0 + [1, 2, 3, 4], + weights: # input 1 + [1, 3, 5, 7, 9, 11, 13, 15, 17, 2, 4, 6, 8, 10, 12, 14, 16, 18]} + +output0 = {i2: # output 0 + [1, 2, 3, 4, 7, 10, 6, 8, 10, 12, 7, 8, 9, + 10, 25, 28, 18, 20, 22, 24, 16, 20, 24, 28, 62, 72, + 42, 48, 54, 60, 21, 24, 27, 30, 61, 68, 36, 40, 44, + 48, 39, 42, 45, 48, 103, 110, 60, 64, 68, 72]} + +# Instantiate an example +Example((input0, output0)) -- 2.7.4