blob: 53212b58f99212d0caf661e7f81371ebcacfbad8 [file] [log] [blame]
Matthew Jackson74bf7da2019-08-16 16:51:42 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include <boost/test/unit_test.hpp>
7#include "ParserFlatbuffersFixture.hpp"
8#include "../TfLiteParser.hpp"
9
10BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
11
12struct TransposeConvFixture : public ParserFlatbuffersFixture
13{
14 explicit TransposeConvFixture(const std::string& inputShape,
15 const std::string& outputShape,
16 const std::string& filterShape,
17 const std::string& filterData,
Matthew Jackson74bf7da2019-08-16 16:51:42 +010018 const std::string& strideX,
19 const std::string& strideY,
20 const std::string& dataType)
21 {
Matthew Jackson74bf7da2019-08-16 16:51:42 +010022 m_JsonString = R"(
23 {
24 "version": 3,
25 "operator_codes": [ { "builtin_code": "TRANSPOSE_CONV" } ],
26 "subgraphs": [ {
27 "tensors": [
28 {
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010029 "shape": [ 4 ],
30 "type": "UINT8",
Matthew Jackson74bf7da2019-08-16 16:51:42 +010031 "buffer": 0,
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010032 "name": "outputShapeTensor",
Matthew Jackson74bf7da2019-08-16 16:51:42 +010033 "quantization": {
34 "min": [ 0.0 ],
35 "max": [ 255.0 ],
36 "scale": [ 1.0 ],
37 "zero_point": [ 0 ],
38 }
39 },
40 {
41 "shape": )" + filterShape + R"(,
42 "type": ")" + dataType + R"(",
43 "buffer": 1,
44 "name": "filterTensor",
45 "quantization": {
46 "min": [ 0.0 ],
47 "max": [ 255.0 ],
48 "scale": [ 1.0 ],
49 "zero_point": [ 0 ],
50 }
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010051 },
52 {
53 "shape": )" + inputShape + R"(,
54 "type": ")" + dataType + R"(",
55 "buffer": 2,
56 "name": "inputTensor",
57 "quantization": {
58 "min": [ 0.0 ],
59 "max": [ 255.0 ],
60 "scale": [ 1.0 ],
61 "zero_point": [ 0 ],
62 }
63 },
Matthew Jackson74bf7da2019-08-16 16:51:42 +010064 {
65 "shape": )" + outputShape + R"(,
66 "type": ")" + dataType + R"(",
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010067 "buffer": 3,
Matthew Jackson74bf7da2019-08-16 16:51:42 +010068 "name": "outputTensor",
69 "quantization": {
70 "min": [ 0.0 ],
71 "max": [ 255.0 ],
72 "scale": [ 1.0 ],
73 "zero_point": [ 0 ],
74 }
75 }
76 ],
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010077 "inputs": [ 2 ],
78 "outputs": [ 3 ],
Matthew Jackson74bf7da2019-08-16 16:51:42 +010079 "operators": [
80 {
81 "opcode_index": 0,
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010082 "inputs": [ 0, 1, 2 ],
83 "outputs": [ 3 ],
Matthew Jackson74bf7da2019-08-16 16:51:42 +010084 "builtin_options_type": "TransposeConvOptions",
85 "builtin_options": {
86 "padding": "SAME",
87 "stride_w": )" + strideX + R"(,
88 "stride_h": )" + strideY + R"(
89 },
90 "custom_options_format": "FLEXBUFFERS"
91 }
92 ],
93 } ],
94 "buffers" : [
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010095 { "data": )" + outputShape + R"( },
Matthew Jackson74bf7da2019-08-16 16:51:42 +010096 { "data": )" + filterData + R"( },
Matthew Jacksonccb25ea2019-08-20 17:18:33 +010097 { },
Matthew Jackson74bf7da2019-08-16 16:51:42 +010098 { }
99 ]
100 }
101 )";
102 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
103 }
104};
105
106struct SimpleTransposeConvFixture : TransposeConvFixture
107{
108 SimpleTransposeConvFixture()
109 : TransposeConvFixture("[ 1, 2, 2, 1 ]", // inputShape
110 "[ 1, 3, 3, 1 ]", // outputShape
111 "[ 1, 2, 2, 1 ]", // filterShape
112 "[ 0, 1, 2, 4 ]", // filterData
Matthew Jackson74bf7da2019-08-16 16:51:42 +0100113 "1", // strideX
114 "1", // strideY
115 "UINT8") // dataType
116 {}
117};
118
119BOOST_FIXTURE_TEST_CASE( ParseSimpleTransposeConv, SimpleTransposeConvFixture )
120{
121 RunTest<4, armnn::DataType::QuantisedAsymm8>(
122 0,
123 {
124 1, 2,
125 3, 4
126 },
127 {
128 0, 1, 2,
129 2, 11, 12,
130 6, 20, 16
131 });
132}
133
Matthew Jackson74bf7da2019-08-16 16:51:42 +0100134BOOST_AUTO_TEST_SUITE_END()