• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ParserFlatbuffersFixture.hpp"
7 
8 
9 TEST_SUITE("TensorflowLiteParser_ResizeBilinear")
10 {
11 struct ResizeBilinearFixture : public ParserFlatbuffersFixture
12 {
ResizeBilinearFixtureResizeBilinearFixture13     explicit ResizeBilinearFixture(const std::string & inputShape,
14                                    const std::string & outputShape,
15                                    const std::string & sizeShape,
16                                    const std::string & sizeData)
17     {
18         m_JsonString = R"(
19             {
20                 "version": 3,
21                 "operator_codes": [ { "builtin_code": "RESIZE_BILINEAR" } ],
22                 "subgraphs": [ {
23                     "tensors": [
24                         {
25                             "shape": )" + sizeShape + R"( ,
26                             "type": "INT32",
27                             "buffer": 0,
28                             "name": "sizeTensor",
29                             "quantization": {
30                                 "min": [ 0.0 ],
31                                 "max": [ 255.0 ],
32                                 "scale": [ 1.0 ],
33                                 "zero_point": [ 0 ],
34                             }
35                         },
36                         {
37                             "shape": )" + inputShape + R"(,
38                             "type": "FLOAT32",
39                             "buffer": 1,
40                             "name": "InputTensor",
41                             "quantization": {
42                                 "min": [ 0.0 ],
43                                 "max": [ 255.0 ],
44                                 "scale": [ 1.0 ],
45                                 "zero_point": [ 0 ],
46                             }
47                         },
48                         {
49                             "shape": )" + outputShape + R"( ,
50                             "type": "FLOAT32",
51                             "buffer": 2,
52                             "name": "OutputTensor",
53                             "quantization": {
54                                 "min": [ 0.0 ],
55                                 "max": [ 255.0 ],
56                                 "scale": [ 1.0 ],
57                                 "zero_point": [ 0 ],
58                             }
59                         }
60                     ],
61                 "inputs": [ 1 ],
62                 "outputs": [ 2 ],
63                 "operators": [
64                     {
65                         "opcode_index": 0,
66                         "inputs": [ 1, 0 ],
67                         "outputs": [ 2 ],
68                         "builtin_options_type": "ResizeBilinearOptions",
69                         "builtin_options": {
70                         },
71                         "custom_options_format": "FLEXBUFFERS"
72                     }
73                 ],
74               } ],
75               "buffers" : [
76                   { "data": )" + sizeData + R"(, },
77                   { },
78                   { },
79               ]
80             }
81       )";
82       Setup();
83     }
84 };
85 
86 
87 struct SimpleResizeBilinearFixture : ResizeBilinearFixture
88 {
SimpleResizeBilinearFixtureSimpleResizeBilinearFixture89     SimpleResizeBilinearFixture()
90         : ResizeBilinearFixture("[ 1, 3, 3, 1 ]",         // inputShape
91                                 "[ 1, 5, 5, 1 ]",         // outputShape
92                                 "[ 2 ]",                  // sizeShape
93                                 "[  5,0,0,0, 5,0,0,0 ]")  // sizeData
94     {}
95 };
96 
97 TEST_CASE_FIXTURE(SimpleResizeBilinearFixture, "ParseResizeBilinear")
98 {
99     RunTest<4, armnn::DataType::Float32>(
100                 0,
101                 {{"InputTensor", { 0.0f, 1.0f, 2.0f,
102                                    3.0f, 4.0f, 5.0f,
103                                    6.0f, 7.0f, 8.0f }}},
104                 {{"OutputTensor", { 0.0f, 0.6f, 1.2f, 1.8f, 2.0f,
105                                     1.8f, 2.4f, 3.0f, 3.6f, 3.8f,
106                                     3.6f, 4.2f, 4.8f, 5.4f, 5.6f,
107                                     5.4f, 6.0f, 6.6f, 7.2f, 7.4f,
108                                     6.0f, 6.6f, 7.2f, 7.8f, 8.0f }}}
109                 );
110 }
111 
112 }
113