blob: b43c3c62aa066dd145481c3862d9cc7ebf374bb9 [file] [log] [blame]
Teresa Charlin3ab85482021-06-08 16:59:29 +01001//
Teresa Charlina7a605a2023-06-14 14:51:17 +01002// Copyright © 2021, 2023 Arm Ltd. All rights reserved.
Teresa Charlin3ab85482021-06-08 16:59:29 +01003// SPDX-License-Identifier: MIT
4//
5#include "ParserFlatbuffersFixture.hpp"
Teresa Charlin3ab85482021-06-08 16:59:29 +01006
7#include <string>
Teresa Charlin3ab85482021-06-08 16:59:29 +01008
9TEST_SUITE("TensorflowLiteParser_ExpandDims")
10{
11struct ExpandDimsFixture : public ParserFlatbuffersFixture
12{
13 explicit ExpandDimsFixture(const std::string& inputShape,
14 const std::string& outputShape,
15 const std::string& axis)
16 {
17 m_JsonString = R"(
18 {
19 "version": 3,
20 "operator_codes": [ { "builtin_code": "EXPAND_DIMS" } ],
21 "subgraphs": [ {
22 "tensors": [
23 {
24 "shape": )" + inputShape + R"(,
25 "type": "UINT8",
26 "buffer": 0,
27 "name": "inputTensor",
28 "quantization": {
29 "min": [ 0.0 ],
30 "max": [ 255.0 ],
31 "scale": [ 1.0 ],
32 "zero_point": [ 0 ],
33 }
34 },
35 {
36 "shape": )" + outputShape + R"( ,
37 "type": "UINT8",
38 "buffer": 1,
39 "name": "outputTensor",
40 "quantization": {
41 "min": [ 0.0 ],
42 "max": [ 255.0 ],
43 "scale": [ 1.0 ],
44 "zero_point": [ 0 ],
45 }
46 },
47 {
Teresa Charlina7a605a2023-06-14 14:51:17 +010048 "shape": [],
49 "type": "INT32",
Teresa Charlin3ab85482021-06-08 16:59:29 +010050 "buffer": 2,
51 "name": "expand_dims",
52 "quantization": {
Teresa Charlina7a605a2023-06-14 14:51:17 +010053 "details_type": "NONE",
Teresa Charlin3ab85482021-06-08 16:59:29 +010054 }
55 },
56 ],
57 "inputs": [ 0 ],
58 "outputs": [ 1 ],
59 "operators": [
60 {
61 "opcode_index": 0,
62 "inputs": [ 0 , 2 ],
63 "outputs": [ 1 ],
64 "custom_options_format": "FLEXBUFFERS"
65 }
66 ],
67 } ],
68 "buffers" : [
69 { },
70 { },
71 { "data": )" + axis + R"(, },
72 ]
73 }
74 )";
Teresa Charlina7a605a2023-06-14 14:51:17 +010075 Setup();
Teresa Charlin3ab85482021-06-08 16:59:29 +010076 }
77};
78
79struct ExpandDimsFixture3dto4Daxis0 : ExpandDimsFixture
80{
81 ExpandDimsFixture3dto4Daxis0() : ExpandDimsFixture("[ 2, 2, 1 ]", "[ 1, 2, 2, 1 ]", "[ 0, 0, 0, 0 ]") {}
82};
83
84TEST_CASE_FIXTURE(ExpandDimsFixture3dto4Daxis0, "ParseExpandDims3Dto4Daxis0")
85{
86 RunTest<4, armnn::DataType::QAsymmU8>(0, {{ "inputTensor", { 1, 2, 3, 4 } } },
87 {{ "outputTensor", { 1, 2, 3, 4 } } });
88}
89
90struct ExpandDimsFixture3dto4Daxis3 : ExpandDimsFixture
91{
92 ExpandDimsFixture3dto4Daxis3() : ExpandDimsFixture("[ 1, 2, 2 ]", "[ 1, 2, 2, 1 ]", "[ 3, 0, 0, 0 ]") {}
93};
94
95TEST_CASE_FIXTURE(ExpandDimsFixture3dto4Daxis3, "ParseExpandDims3Dto4Daxis3")
96{
97 RunTest<4, armnn::DataType::QAsymmU8>(0, {{ "inputTensor", { 1, 2, 3, 4 } } },
98 {{ "outputTensor", { 1, 2, 3, 4 } } });
99}
100
101}