ArmNN
 22.05
PadV2.cpp File Reference

Go to the source code of this file.

Functions

 TEST_SUITE ("TensorflowLiteParser_Pad")
 

Function Documentation

◆ TEST_SUITE()

TEST_SUITE ( "TensorflowLiteParser_Pad"  )

Definition at line 9 of file PadV2.cpp.

References ParserFlatbuffersFixture::SetupSingleInputSingleOutput(), and TEST_CASE_FIXTURE().

10 {
11 struct PadV2Fixture : public ParserFlatbuffersFixture
12 {
13  explicit PadV2Fixture(const std::string& inputShape,
14  const std::string& outputShape,
15  const std::string& padListShape,
16  const std::string& padListData,
17  const std::string& constantValuesShape,
18  const std::string& constantValuesData,
19  const std::string& dataType = "FLOAT32",
20  const std::string& scale = "1.0",
21  const std::string& offset = "0")
22  {
23  m_JsonString = R"(
24  {
25  "version": 3,
26  "operator_codes": [ { "builtin_code": "PADV2" } ],
27  "subgraphs": [ {
28  "tensors": [
29  {
30  "shape": )" + inputShape + R"(,
31  "type": )" + dataType + R"(,
32  "buffer": 0,
33  "name": "inputTensor",
34  "quantization": {
35  "min": [ 0.0 ],
36  "max": [ 255.0 ],
37  "scale": [ )" + scale + R"( ],
38  "zero_point": [ )" + offset + R"( ],
39  }
40  },
41  {
42  "shape": )" + outputShape + R"(,
43  "type": )" + dataType + R"(,
44  "buffer": 1,
45  "name": "outputTensor",
46  "quantization": {
47  "min": [ 0.0 ],
48  "max": [ 255.0 ],
49  "scale": [ )" + scale + R"( ],
50  "zero_point": [ )" + offset + R"( ],
51  }
52  },
53  {
54  "shape": )" + padListShape + R"( ,
55  "type": "INT64",
56  "buffer": 2,
57  "name": "padList",
58  "quantization": {
59  "min": [ 0.0 ],
60  "max": [ 255.0 ],
61  "scale": [ 1.0 ],
62  "zero_point": [ 0 ],
63  }
64  },
65  {
66  "shape": )" + constantValuesShape + R"( ,
67  "type": )" + dataType + R"(,
68  "buffer": 3,
69  "name": "constantValues",
70  "quantization": {
71  "min": [ 0.0 ],
72  "max": [ 255.0 ],
73  "scale": [ 1.0 ],
74  "zero_point": [ 0 ],
75  }
76  }
77  ],
78  "inputs": [ 0 ],
79  "outputs": [ 1 ],
80  "operators": [
81  {
82  "opcode_index": 0,
83  "inputs": [ 0, 2, 3 ],
84  "outputs": [ 1 ],
85  "custom_options_format": "FLEXBUFFERS"
86  }
87  ],
88  } ],
89  "buffers" : [
90  { },
91  { },
92  { "data": )" + padListData + R"(, },
93  { "data": )" + constantValuesData + R"(, },
94  ]
95  }
96  )";
97  SetupSingleInputSingleOutput("inputTensor", "outputTensor");
98  }
99 };
100 
101 struct SimplePadV2Fixture : public PadV2Fixture
102 {
103  SimplePadV2Fixture() : PadV2Fixture("[ 2,3 ]", "[ 4,7 ]", "[ 2,2 ]",
104  "[ 1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0 ]",
105  "[1]", "[0,0,160,64]") {}
106 };
107 
108 TEST_CASE_FIXTURE(SimplePadV2Fixture, "ParsePadV2")
109 {
110  RunTest<2, armnn::DataType::Float32>
111  (0,
112  {{ "inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }}},
113  {{ "outputTensor", { 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f,
114  5.0f, 5.0f, 1.0f, 2.0f, 3.0f, 5.0f, 5.0f,
115  5.0f, 5.0f, 4.0f, 5.0f, 6.0f, 5.0f, 5.0f,
116  5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f }}});
117 }
118 
119 struct NoConstValuePadV2Fixture : public PadV2Fixture
120 {
121  NoConstValuePadV2Fixture() : PadV2Fixture("[ 2,3 ]", "[ 4,7 ]", "[ 2,2 ]",
122  "[ 1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0 ]",
123  "[]", "[]") {}
124 };
125 
126 TEST_CASE_FIXTURE(NoConstValuePadV2Fixture, "ParsePadV2NoConstValue")
127 {
128  RunTest<2, armnn::DataType::Float32>
129  (0,
130  {{ "inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }}},
131  {{ "outputTensor", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, .0f,
132  0.0f, 0.0f, 1.0f, 2.0f, 3.0f, 0.0f, 0.0f,
133  0.0f, 0.0f, 4.0f, 5.0f, 6.0f, 0.0f, 0.0f,
134  0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }}});
135 }
136 
137 struct Uint8PadV2Fixture : public PadV2Fixture
138 {
139  Uint8PadV2Fixture() : PadV2Fixture("[ 2,3 ]", "[ 4,7 ]", "[ 2,2 ]",
140  "[ 1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0 ]",
141  "[1]", "[1]","UINT8", "-2.0", "3") {}
142 };
143 
144 TEST_CASE_FIXTURE(Uint8PadV2Fixture, "ParsePadV2Uint8")
145 {
146  RunTest<2, armnn::DataType::QAsymmU8>
147  (0,
148  {{ "inputTensor", { 1, 2, 3, 4, 5, 6 }}},
149  {{ "outputTensor", { 1, 1, 1, 1, 1, 1, 1,
150  1, 1, 1, 2, 3, 1, 1,
151  1, 1, 4, 5, 6, 1, 1,
152  1, 1, 1, 1, 1, 1, 1 }}});
153 }
154 
155 struct Int8PadV2Fixture : public PadV2Fixture
156 {
157  Int8PadV2Fixture() : PadV2Fixture("[ 2,3 ]", "[ 4,7 ]", "[ 2,2 ]",
158  "[ 1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0 ]",
159  "[1]", "[2]","INT8", "-2.0", "3") {}
160 };
161 
162 TEST_CASE_FIXTURE(Int8PadV2Fixture, "ParsePadV2Int8")
163 {
164  RunTest<2, armnn::DataType::QAsymmS8>
165  (0,
166  {{ "inputTensor", { 1, -2, 3, 4, 5, -6 }}},
167  {{ "outputTensor", { 2, 2, 2, 2, 2, 2, 2,
168  2, 2, 1, -2, 3, 2, 2,
169  2, 2, 4, 5, -6, 2, 2,
170  2, 2, 2, 2, 2, 2, 2 }}});
171 }
172 
173 }
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")
void SetupSingleInputSingleOutput(const std::string &inputName, const std::string &outputName)