blob: 948f4fe0cdae791c398ea350651013159bebd0f0 [file] [log] [blame]
Sadik Armagana3b31f02019-12-05 09:08:53 +00001//
2// Copyright © 2019 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Sadik Armagana3b31f02019-12-05 09:08:53 +00006#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_ResizeNearestNeighbor")
13{
Sadik Armagana3b31f02019-12-05 09:08:53 +000014struct ResizeNearestNeighborFixture : public ParserFlatbuffersFixture
15{
16 explicit ResizeNearestNeighborFixture(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_NEAREST_NEIGHBOR" } ],
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": "ResizeNearestNeighborOptions",
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 SimpleResizeNearestNeighborFixture : ResizeNearestNeighborFixture
91{
92 SimpleResizeNearestNeighborFixture()
93 : ResizeNearestNeighborFixture("[ 1, 2, 2, 1 ]", // inputShape
94 "[ 1, 1, 1, 1 ]", // outputShape
95 "[ 2 ]", // sizeShape
96 "[ 1,0,0,0, 1,0,0,0 ]") // sizeData
97 {}
98};
99
Sadik Armagan1625efc2021-06-10 18:24:34 +0100100TEST_CASE_FIXTURE(SimpleResizeNearestNeighborFixture, "ParseResizeNearestNeighbor")
Sadik Armagana3b31f02019-12-05 09:08:53 +0000101{
102 RunTest<4, armnn::DataType::Float32>(
103 0,
104 {{"InputTensor", { 1.0f, 2.0f, 3.0f, 4.0f }}},
105 {{"OutputTensor", { 1.0f }}});
106}
107
Sadik Armagan1625efc2021-06-10 18:24:34 +0100108}