blob: 9604a3a1dead7cb498c95c6cd9eb101135f86bc1 [file] [log] [blame]
Tianle Chenge5a30ff2023-07-03 11:24:12 +01001//
2// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersFixture.hpp"
7
8TEST_SUITE("TensorflowLiteParser_ReverseV2")
9{
10struct ReverseV2Fixture : public ParserFlatbuffersFixture
11{
12 explicit ReverseV2Fixture(const std::string& inputShape,
13 const std::string& outputShape,
14 const std::string& axisShape,
15 const std::string& axisData,
16 const std::string& dataType = "FLOAT32",
17 const std::string& scale = "1.0",
18 const std::string& offset = "0")
19 {
20 m_JsonString = R"(
21 {
22 "version": 3,
23 "operator_codes": [ { "builtin_code": "REVERSE_V2" } ],
24 "subgraphs": [ {
25 "tensors": [
26 {
27 "shape": )" + inputShape + R"(,
28 "type": )" + dataType + R"(,
29 "buffer": 0,
30 "name": "inputTensor",
31 "quantization": {
32 "min": [ 0.0 ],
33 "max": [ 255.0 ],
34 "scale": [ )" + scale + R"( ],
35 "zero_point": [ )" + offset + R"( ],
36 }
37 },
38 {
39 "shape": )" + axisShape + R"( ,
40 "type": "INT32",
41 "buffer": 1,
42 "name": "axis",
43 "quantization": {
44 "min": [ 0.0 ],
45 "max": [ 255.0 ],
46 "scale": [ 1.0 ],
47 "zero_point": [ 0 ],
48 }
49 },
50 {
51 "shape": )" + outputShape + R"(,
52 "type": )" + dataType + R"(,
53 "buffer": 2,
54 "name": "outputTensor",
55 "quantization": {
56 "min": [ 0.0 ],
57 "max": [ 255.0 ],
58 "scale": [ )" + scale + R"( ],
59 "zero_point": [ )" + offset + R"( ],
60 }
61 }
62 ],
63 "inputs": [ 0, 1 ],
64 "outputs": [ 2 ],
65 "operators": [
66 {
67 "opcode_index": 0,
68 "inputs": [ 0, 1 ],
69 "outputs": [ 2 ],
70 "builtin_options_type": "ReverseV2Options",
71 "builtin_options": {},
72 "custom_options_format": "FLEXBUFFERS"
73 }
74 ],
75 } ],
76 "buffers" : [
77 { },
78 { "data": )" + axisData + R"(, },
79 { },
80 ]
81 }
82 )";
83 Setup();
84 }
85};
86
87struct SimpleReverseV2Fixture : public ReverseV2Fixture
88{
89 SimpleReverseV2Fixture() : ReverseV2Fixture("[ 2, 2, 2 ]", "[ 2, 2, 2 ]", "[ 2 ]", "[ 0,0,0,0, 1,0,0,0 ]") {}
90};
91
92TEST_CASE_FIXTURE(SimpleReverseV2Fixture, "ParseReverseV2")
93{
94 RunTest<3, armnn::DataType::Float32>
95 (0,
96 {{ "inputTensor", { 1, 2, 3, 4, 5, 6, 7, 8 }}},
97 {{ "outputTensor", { 7, 8, 5, 6, 3, 4, 1, 2 }}});
98}
99
100}