blob: 8af5612b9e2355aa945037d4933cf5fc586a7e61 [file] [log] [blame]
Bruno Goncalves3f58ddb2019-02-07 18:40:11 -02001//
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
10#include <string>
11#include <iostream>
12
Bruno Goncalves3f58ddb2019-02-07 18:40:11 -020013BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
14
15struct ResizeBilinearFixture : public ParserFlatbuffersFixture
16{
17 explicit ResizeBilinearFixture(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_BILINEAR" } ],
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": "ResizeBilinearOptions",
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
91struct SimpleResizeBilinearFixture : ResizeBilinearFixture
92{
93 SimpleResizeBilinearFixture()
94 : ResizeBilinearFixture("[ 1, 3, 3, 1 ]", // inputShape
95 "[ 1, 5, 5, 1 ]", // outputShape
96 "[ 2 ]", // sizeShape
97 "[ 5,0,0,0, 5,0,0,0 ]") // sizeData
98 {}
99};
100
101BOOST_FIXTURE_TEST_CASE(ParseResizeBilinear, SimpleResizeBilinearFixture)
102{
103 RunTest<4, armnn::DataType::Float32>(
104 0,
105 {{"InputTensor", { 0.0f, 1.0f, 2.0f,
106 3.0f, 4.0f, 5.0f,
107 6.0f, 7.0f, 8.0f }}},
108 {{"OutputTensor", { 0.0f, 0.6f, 1.2f, 1.8f, 2.0f,
109 1.8f, 2.4f, 3.0f, 3.6f, 3.8f,
110 3.6f, 4.2f, 4.8f, 5.4f, 5.6f,
111 5.4f, 6.0f, 6.6f, 7.2f, 7.4f,
112 6.0f, 6.6f, 7.2f, 7.8f, 8.0f }}}
113 );
114}
115
116BOOST_AUTO_TEST_SUITE_END()