blob: b0c663ac8bc1223cdb03cc33cf7775982223edeb [file] [log] [blame]
Teresa Charlin777008b2023-07-26 10:07:55 +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_Tile")
9{
10struct TileFixture : public ParserFlatbuffersFixture
11{
12 explicit TileFixture(const std::string& inputShape,
13 const std::string& outputShape,
14 const std::string& multiplesShape,
15 const std::string& multiplesData,
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": [
24 {
25 "deprecated_builtin_code": 69,
26 "version": 1,
27 "builtin_code": "TILE"
28 }
29 ],
30 "subgraphs": [
31 {
32 "tensors": [
33 {
34 "shape": )" + inputShape + R"(,
35 "type": )" + dataType + R"(,
36 "buffer": 1,
37 "name": "inputTensor",
38 "quantization": {
39 "min": [ 0.0 ],
40 "max": [ 255.0 ],
41 "scale": [ )" + scale + R"( ],
42 "zero_point": [ )" + offset + R"( ],
43 },
44 "is_variable": false,
45 "has_rank": true
46 },
47 {
48 "shape": )" + multiplesShape + R"(,
49 "type": "INT32",
50 "buffer": 2,
51 "name": "multiples",
52 "quantization": {
53 "details_type": "NONE",
54 "quantized_dimension": 0
55 },
56 "is_variable": false,
57 "has_rank": true
58 },
59 {
60 "shape": )" + outputShape + R"(,
61 "type": )" + dataType + R"(,
62 "buffer": 3,
63 "name": "outputTensor",
64 "quantization": {
65 "min": [ 0.0 ],
66 "max": [ 255.0 ],
67 "scale": [ )" + scale + R"( ],
68 "zero_point": [ )" + offset + R"( ],
69 },
70 "is_variable": false,
71 "has_rank": true
72 }
73 ],
74 "inputs": [ 0 ],
75 "outputs": [ 2 ],
76 "operators": [
77 {
78 "opcode_index": 0,
79 "inputs": [ 0, 1 ],
80 "outputs": [ 2 ],
81 "builtin_options_type": "NONE",
82 "custom_options_format": "FLEXBUFFERS"
83 }
84 ],
85 } ],
86 "buffers" : [
87 { },
88 { },
89 { "data": )" + multiplesData + R"(, },
90 ]
91 }
92 )";
93 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
94 }
95};
96
97struct SimpleTileFixture : public TileFixture
98{
99 SimpleTileFixture() : TileFixture("[ 2, 2 ]", "[ 4, 6 ]", "[ 2 ]", "[ 2, 0, 0, 0, 3, 0, 0, 0 ]") {}
100};
101
102TEST_CASE_FIXTURE(SimpleTileFixture, "ParseTile")
103{
104 RunTest<2, armnn::DataType::Float32, armnn::DataType::Float32>
105 (0,
106 {{ "inputTensor", { 1, 2,
107 3, 4 }}},
108 {{ "outputTensor", { 1, 2, 1, 2, 1, 2,
109 3, 4, 3, 4, 3, 4,
110 1, 2, 1, 2, 1, 2,
111 3, 4, 3, 4, 3, 4, }}});
112}
113
114}