blob: 46fa80fce631294f2448776b20f5df98b80335f5 [file] [log] [blame]
Keith Davis0176fd82021-06-01 17:36:32 +01001//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersFixture.hpp"
Keith Davis0176fd82021-06-01 17:36:32 +01007
8TEST_SUITE("TensorflowLiteParser_Shape")
9{
10struct ShapeFixture : public ParserFlatbuffersFixture
11{
12 explicit ShapeFixture(const std::string& inputShape,
13 const std::string& outputShape,
14 const std::string& inputDataType,
15 const std::string& outputDataType)
16 {
17 m_JsonString = R"(
18 {
19 "version": 3,
20 "operator_codes": [ { "builtin_code": "SHAPE" } ],
21 "subgraphs": [ {
22 "tensors": [
23 {
24 "shape": )" + inputShape + R"(,
25 "type": )" + inputDataType + R"(,
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": )" + outputDataType + R"(,
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 ],
48 "inputs": [ 0 ],
49 "outputs": [ 1 ],
50 "operators": [
51 {
52 "opcode_index": 0,
53 "inputs": [ 0 ],
54 "outputs": [ 1 ],
55 "custom_options_format": "FLEXBUFFERS"
56 }
57 ],
58 } ],
59 "buffers" : [ {}, {} ]
60 }
61 )";
62 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
63 }
64};
65
66
67struct SimpleShapeFixture : ShapeFixture
68{
69 SimpleShapeFixture() : ShapeFixture("[ 1, 3, 3, 1 ]",
70 "[ 4 ]",
71 "INT32",
72 "INT32") {}
73};
74
75TEST_CASE_FIXTURE(SimpleShapeFixture, "SimpleShapeFixture")
76{
77 RunTest<1, armnn::DataType::Signed32>(
78 0,
79 {{"inputTensor", { 1, 1, 1, 1, 1, 1, 1, 1, 1 }}},
80 {{"outputTensor",{ 1, 3, 3, 1 }}});
81}
82
83}