blob: 400dc78b67915b3e981277c0f14bd52895edc402 [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
13using armnnTfLiteParser::TfLiteParser;
14
15BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
16
17struct ResizeBilinearFixture : public ParserFlatbuffersFixture
18{
19 explicit ResizeBilinearFixture(const std::string & inputShape,
20 const std::string & outputShape,
21 const std::string & sizeShape,
22 const std::string & sizeData)
23 {
24 m_JsonString = R"(
25 {
26 "version": 3,
27 "operator_codes": [ { "builtin_code": "RESIZE_BILINEAR" } ],
28 "subgraphs": [ {
29 "tensors": [
30 {
31 "shape": )" + sizeShape + R"( ,
32 "type": "INT32",
33 "buffer": 0,
34 "name": "sizeTensor",
35 "quantization": {
36 "min": [ 0.0 ],
37 "max": [ 255.0 ],
38 "scale": [ 1.0 ],
39 "zero_point": [ 0 ],
40 }
41 },
42 {
43 "shape": )" + inputShape + R"(,
44 "type": "FLOAT32",
45 "buffer": 1,
46 "name": "InputTensor",
47 "quantization": {
48 "min": [ 0.0 ],
49 "max": [ 255.0 ],
50 "scale": [ 1.0 ],
51 "zero_point": [ 0 ],
52 }
53 },
54 {
55 "shape": )" + outputShape + R"( ,
56 "type": "FLOAT32",
57 "buffer": 2,
58 "name": "OutputTensor",
59 "quantization": {
60 "min": [ 0.0 ],
61 "max": [ 255.0 ],
62 "scale": [ 1.0 ],
63 "zero_point": [ 0 ],
64 }
65 }
66 ],
67 "inputs": [ 1 ],
68 "outputs": [ 2 ],
69 "operators": [
70 {
71 "opcode_index": 0,
72 "inputs": [ 1, 0 ],
73 "outputs": [ 2 ],
74 "builtin_options_type": "ResizeBilinearOptions",
75 "builtin_options": {
76 },
77 "custom_options_format": "FLEXBUFFERS"
78 }
79 ],
80 } ],
81 "buffers" : [
82 { "data": )" + sizeData + R"(, },
83 { },
84 { },
85 ]
86 }
87 )";
88 Setup();
89 }
90};
91
92
93struct SimpleResizeBilinearFixture : ResizeBilinearFixture
94{
95 SimpleResizeBilinearFixture()
96 : ResizeBilinearFixture("[ 1, 3, 3, 1 ]", // inputShape
97 "[ 1, 5, 5, 1 ]", // outputShape
98 "[ 2 ]", // sizeShape
99 "[ 5,0,0,0, 5,0,0,0 ]") // sizeData
100 {}
101};
102
103BOOST_FIXTURE_TEST_CASE(ParseResizeBilinear, SimpleResizeBilinearFixture)
104{
105 RunTest<4, armnn::DataType::Float32>(
106 0,
107 {{"InputTensor", { 0.0f, 1.0f, 2.0f,
108 3.0f, 4.0f, 5.0f,
109 6.0f, 7.0f, 8.0f }}},
110 {{"OutputTensor", { 0.0f, 0.6f, 1.2f, 1.8f, 2.0f,
111 1.8f, 2.4f, 3.0f, 3.6f, 3.8f,
112 3.6f, 4.2f, 4.8f, 5.4f, 5.6f,
113 5.4f, 6.0f, 6.6f, 7.2f, 7.4f,
114 6.0f, 6.6f, 7.2f, 7.8f, 8.0f }}}
115 );
116}
117
118BOOST_AUTO_TEST_SUITE_END()