blob: b885284e62e775776985acace2432269efd60e59 [file] [log] [blame]
Sadik Armagana3b31f02019-12-05 09:08:53 +00001//
Finn Williamsb49ed182021-06-29 15:50:08 +01002// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
Sadik Armagana3b31f02019-12-05 09:08:53 +00003// SPDX-License-Identifier: MIT
4//
5
Sadik Armagana3b31f02019-12-05 09:08:53 +00006#include "ParserFlatbuffersFixture.hpp"
Sadik Armagana3b31f02019-12-05 09:08:53 +00007
Sadik Armagana3b31f02019-12-05 09:08:53 +00008
Sadik Armagan1625efc2021-06-10 18:24:34 +01009TEST_SUITE("TensorflowLiteParser_ResizeNearestNeighbor")
10{
Sadik Armagana3b31f02019-12-05 09:08:53 +000011struct ResizeNearestNeighborFixture : public ParserFlatbuffersFixture
12{
13 explicit ResizeNearestNeighborFixture(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_NEAREST_NEIGHBOR" } ],
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": "ResizeNearestNeighborOptions",
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
87struct SimpleResizeNearestNeighborFixture : ResizeNearestNeighborFixture
88{
89 SimpleResizeNearestNeighborFixture()
90 : ResizeNearestNeighborFixture("[ 1, 2, 2, 1 ]", // inputShape
91 "[ 1, 1, 1, 1 ]", // outputShape
92 "[ 2 ]", // sizeShape
93 "[ 1,0,0,0, 1,0,0,0 ]") // sizeData
94 {}
95};
96
Sadik Armagan1625efc2021-06-10 18:24:34 +010097TEST_CASE_FIXTURE(SimpleResizeNearestNeighborFixture, "ParseResizeNearestNeighbor")
Sadik Armagana3b31f02019-12-05 09:08:53 +000098{
99 RunTest<4, armnn::DataType::Float32>(
100 0,
101 {{"InputTensor", { 1.0f, 2.0f, 3.0f, 4.0f }}},
102 {{"OutputTensor", { 1.0f }}});
103}
104
Sadik Armagan1625efc2021-06-10 18:24:34 +0100105}