From: 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 13 Jun 2019 22:07:55 +0000 (+0900) Subject: Add transpose conv gtest (#5391) X-Git-Tag: submit/tizen/20190809.050447~683 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f86f145e23b012e6d7607a39e41c1b15d40ffadd;p=platform%2Fcore%2Fml%2Fnnfw.git Add transpose conv gtest (#5391) * Add transpose conv gtest Add transpose conv gtest - stride: 2 - same padding Signed-off-by: Hyeongseok Oh * Update skiplist --- diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux b/tests/nnapi/nnapi_gtest.skip.armv7l-linux index c81277a..a444521 100644 --- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux +++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux @@ -12,6 +12,7 @@ GeneratedTests.prelu_ex_quant8_1 GeneratedTests.prelu_ex_broadcast_quant8_1 # Unexpected result GeneratedTests.pack* +GeneratedTests.transpose_conv_ex_float_4 # Not support broadcast GeneratedTests.logical_or_ex_broadcast_4D_2D # Unsupported optional input that has shape diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.pacl b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.pacl index 3606270..25833b9 100644 --- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.pacl +++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.pacl @@ -18,6 +18,7 @@ GeneratedTests.prelu_ex_broadcast_quant8_1 GeneratedTests.svdf GeneratedTests.svdf2 GeneratedTests.svdf_state +GeneratedTests.transpose_conv_ex_float_4 ValidationTestCompilation.CreateExecution ValidationTestCompilation.Finish ValidationTestCompilation.SetPreference diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-tizen b/tests/nnapi/nnapi_gtest.skip.armv7l-tizen index a188c28..7601458 100644 --- a/tests/nnapi/nnapi_gtest.skip.armv7l-tizen +++ b/tests/nnapi/nnapi_gtest.skip.armv7l-tizen @@ -28,6 +28,7 @@ GeneratedTests.prelu_ex* GeneratedTests.svdf GeneratedTests.svdf2 GeneratedTests.svdf_state +GeneratedTests.transpose_conv_ex_float_4 ValidationTestCompilation.CreateExecution ValidationTestCompilation.Finish ValidationTestCompilation.SetPreference diff --git a/tests/nnapi/specs/Ex/transpose_conv_ex_float_4.mod.py b/tests/nnapi/specs/Ex/transpose_conv_ex_float_4.mod.py new file mode 100644 index 0000000..71383b4 --- /dev/null +++ b/tests/nnapi/specs/Ex/transpose_conv_ex_float_4.mod.py @@ -0,0 +1,56 @@ +# model +model = Model() +i0 = Input("op_shape", "TENSOR_INT32", "{4}") +weights = Input("ker", "TENSOR_FLOAT32", "{1, 3, 3, 1}") +i1 = Input("in", "TENSOR_FLOAT32", "{1, 4, 4, 1}" ) +pad = Int32Scalar("pad_same", 1) +s_x = Int32Scalar("stride_x", 2) +s_y = Int32Scalar("stride_y", 2) +i2 = Output("op", "TENSOR_FLOAT32", "{1, 8, 8, 1}") +model = model.Operation("TRANSPOSE_CONV_EX", i0, weights, i1, pad, s_x, s_y).To(i2) + +batch = 1 +in_chans = 1 +out_chans = 1 +in_rows = 4 +in_cols = 4 +out_rows = 8 +out_cols = 8 +ker_rows = 3 +ker_cols = 3 +stride = 2 +# pad is 0 (left: 0 right: 1 top: 0 bottom: 1) +input_table = [x for x in range(batch * in_rows * in_cols * in_chans)] +kernel_table = [x for x in range(out_chans * ker_rows * ker_cols * in_chans)] +out_table = [0 for x in range(batch * out_rows * out_cols * out_chans)] + +for i in range(batch): + for j in range(in_rows): + for k in range(in_cols): + for l in range(in_chans): + out_row_origin = j * stride + out_col_origin = k * stride + input_value = input_table[((i * in_rows + j) * in_cols + k) * in_chans + l] + + for m in range(ker_rows): + for n in range(ker_cols): + for o in range(out_chans): + out_row = out_row_origin + m + out_col = out_col_origin + n + if (out_row < out_rows) and (out_col < out_cols) and (out_row >= 0) and (out_col >= 0): + kernel_value = kernel_table[((o * ker_rows + m) * ker_cols + n) * in_chans + l] + out_table[((i * out_rows + out_row) * out_cols + out_col) * out_chans + o] += (input_value * kernel_value) + +# Example 1. Input in operand 0, +input0 = {i0: # output shape + [1, 8, 8, 1], + i1: # input 0 + input_table, + weights: # input 1 + kernel_table} + +output0 = {i2: # output 0 + out_table} + +# Instantiate an example +Example((input0, output0))