ArmNN
 22.05
GatherNd.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 
9 TEST_SUITE("TensorflowLiteParser_GatherNd")
10 {
11 struct GatherNdFixture : public ParserFlatbuffersFixture
12 {
13  explicit GatherNdFixture(const std::string& paramsShape,
14  const std::string& indicesShape,
15  const std::string& outputShape,
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": "GATHER_ND" } ],
24  "subgraphs": [ {
25  "tensors": [
26  {
27  "shape": )" + paramsShape + R"(,
28  "type": )" + dataType + R"(,
29  "buffer": 0,
30  "name": "params",
31  "quantization": {
32  "min": [ 0.0 ],
33  "max": [ 255.0 ],
34  "scale": [ )" + scale + R"( ],
35  "zero_point": [ )" + offset + R"( ],
36  "details_type": "NONE",
37  "quantized_dimension": 0
38  },
39  "is_variable": false,
40  "shape_signature": )" + paramsShape + R"(
41  },
42  {
43  "shape": )" + indicesShape + R"( ,
44  "type": "INT32",
45  "buffer": 1,
46  "name": "indices",
47  "quantization": {
48  "details_type": "NONE",
49  "quantized_dimension": 0
50  },
51  "is_variable": false
52  },
53  {
54  "shape": )" + outputShape + R"(,
55  "type": )" + dataType + R"(,
56  "buffer": 2,
57  "name": "output",
58  "quantization": {
59  "min": [ 0.0 ],
60  "max": [ 255.0 ],
61  "scale": [ )" + scale + R"( ],
62  "zero_point": [ )" + offset + R"( ],
63  "details_type": "NONE",
64  "quantized_dimension": 0
65  },
66  "is_variable": false,
67  "shape_signature": )" + outputShape + R"(
68  }
69  ],
70  "inputs": [ 0, 1 ],
71  "outputs": [ 2 ],
72  "operators": [
73  {
74  "opcode_index": 0,
75  "inputs": [ 0, 1 ],
76  "outputs": [ 2 ],
77  "builtin_options_type": "NONE",
78  "custom_options_format": "FLEXBUFFERS"
79  }
80  ],
81  } ],
82  "buffers" : [
83  { },
84  { },
85  { },
86  ]
87  }
88  )";
89  Setup();
90  }
91 };
92 
93 struct SimpleGatherNdFixture : public GatherNdFixture
94 {
95  SimpleGatherNdFixture() : GatherNdFixture("[ 5, 2 ]", "[ 3, 1 ]", "[ 3, 2 ]" ) {}
96 };
97 
98 TEST_CASE_FIXTURE(SimpleGatherNdFixture, "ParseGatherNd")
99 {
100  RunTest<2, armnn::DataType::Float32, armnn::DataType::Signed32, armnn::DataType::Float32>
101  (0,
102  {{ "params", { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }}},
103  {{ "indices", { 1, 3, 4 }}},
104  {{ "output", { 3, 4, 7, 8, 9, 10 }}});
105 }
106 
107 struct GatherNdUint8Fixture : public GatherNdFixture
108 {
109  GatherNdUint8Fixture() : GatherNdFixture("[ 8 ]", "[ 3, 1 ]", "[ 3 ]", "UINT8") {}
110 };
111 
112 TEST_CASE_FIXTURE(GatherNdUint8Fixture, "ParseGatherNdUint8")
113 {
114  RunTest<1, armnn::DataType::QAsymmU8, armnn::DataType::Signed32, armnn::DataType::QAsymmU8>
115  (0,
116  {{ "params", { 1, 2, 3, 4, 5, 6, 7, 8 }}},
117  {{ "indices", { 7, 6, 5 }}},
118  {{ "output", { 8, 7, 6 }}});
119 }
120 
121 }
TEST_SUITE("TensorflowLiteParser_GatherNd")
Definition: GatherNd.cpp:9
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")
void Setup(bool testDynamic=true)