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