ArmNN
 21.02
ResizeNearestNeighbor.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <boost/test/unit_test.hpp>
8 #include "../TfLiteParser.hpp"
9 
10 #include <string>
11 #include <iostream>
12 
13 BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
14 
15 struct ResizeNearestNeighborFixture : public ParserFlatbuffersFixture
16 {
17  explicit ResizeNearestNeighborFixture(const std::string & inputShape,
18  const std::string & outputShape,
19  const std::string & sizeShape,
20  const std::string & sizeData)
21  {
22  m_JsonString = R"(
23  {
24  "version": 3,
25  "operator_codes": [ { "builtin_code": "RESIZE_NEAREST_NEIGHBOR" } ],
26  "subgraphs": [ {
27  "tensors": [
28  {
29  "shape": )" + sizeShape + R"( ,
30  "type": "INT32",
31  "buffer": 0,
32  "name": "sizeTensor",
33  "quantization": {
34  "min": [ 0.0 ],
35  "max": [ 255.0 ],
36  "scale": [ 1.0 ],
37  "zero_point": [ 0 ],
38  }
39  },
40  {
41  "shape": )" + inputShape + R"(,
42  "type": "FLOAT32",
43  "buffer": 1,
44  "name": "InputTensor",
45  "quantization": {
46  "min": [ 0.0 ],
47  "max": [ 255.0 ],
48  "scale": [ 1.0 ],
49  "zero_point": [ 0 ],
50  }
51  },
52  {
53  "shape": )" + outputShape + R"( ,
54  "type": "FLOAT32",
55  "buffer": 2,
56  "name": "OutputTensor",
57  "quantization": {
58  "min": [ 0.0 ],
59  "max": [ 255.0 ],
60  "scale": [ 1.0 ],
61  "zero_point": [ 0 ],
62  }
63  }
64  ],
65  "inputs": [ 1 ],
66  "outputs": [ 2 ],
67  "operators": [
68  {
69  "opcode_index": 0,
70  "inputs": [ 1, 0 ],
71  "outputs": [ 2 ],
72  "builtin_options_type": "ResizeNearestNeighborOptions",
73  "builtin_options": {
74  },
75  "custom_options_format": "FLEXBUFFERS"
76  }
77  ],
78  } ],
79  "buffers" : [
80  { "data": )" + sizeData + R"(, },
81  { },
82  { },
83  ]
84  }
85  )";
86  Setup();
87  }
88 };
89 
90 
91 struct SimpleResizeNearestNeighborFixture : ResizeNearestNeighborFixture
92 {
93  SimpleResizeNearestNeighborFixture()
94  : ResizeNearestNeighborFixture("[ 1, 2, 2, 1 ]", // inputShape
95  "[ 1, 1, 1, 1 ]", // outputShape
96  "[ 2 ]", // sizeShape
97  "[ 1,0,0,0, 1,0,0,0 ]") // sizeData
98  {}
99 };
100 
101 BOOST_FIXTURE_TEST_CASE(ParseResizeNearestNeighbor, SimpleResizeNearestNeighborFixture)
102 {
103  RunTest<4, armnn::DataType::Float32>(
104  0,
105  {{"InputTensor", { 1.0f, 2.0f, 3.0f, 4.0f }}},
106  {{"OutputTensor", { 1.0f }}});
107 }
108 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(ParseResizeNearestNeighbor, SimpleResizeNearestNeighborFixture)
BOOST_AUTO_TEST_SUITE_END()