blob: 5f9e32d202c9097bd80a4eed9f86cd2509329532 [file] [log] [blame]
Teresa Charlin2a764ad2023-02-24 18:17:31 +00001//
2// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersFixture.hpp"
7
8
9TEST_SUITE("TensorflowLiteParser_SpaceToDepth")
10{
11struct SpaceToDepthFixture : public ParserFlatbuffersFixture
12{
13 explicit SpaceToDepthFixture(const std::string& inputShape,
14 const std::string& outputShape,
15 const std::string& dataType = "FLOAT32",
16 const std::string& scale = "1.0",
17 const std::string& offset = "0")
18 {
19 m_JsonString = R"(
20 {
21 "version": 3,
22 "operator_codes": [ { "builtin_code": "DEPTH_TO_SPACE" } ],
23 "subgraphs": [ {
24 "tensors": [
25 {
26 "shape": )" + inputShape + R"(,
27 "type": )" + dataType + R"(,
28 "buffer": 0,
29 "name": "inputTensor",
30 "quantization": {
31 "min": [ 0.0 ],
32 "max": [ 255.0 ],
33 "scale": [ )" + scale + R"( ],
34 "zero_point": [ )" + offset + R"( ],
35 }
36 },
37 {
38 "shape": )" + outputShape + R"(,
39 "type": )" + dataType + R"(,
40 "buffer": 1,
41 "name": "outputTensor",
42 "quantization": {
43 "min": [ 0.0 ],
44 "max": [ 255.0 ],
45 "scale": [ )" + scale + R"( ],
46 "zero_point": [ )" + offset + R"( ],
47 }
48 }
49 ],
50 "inputs": [ 0 ],
51 "outputs": [ 1 ],
52 "operators": [
53 {
54 "opcode_index": 0,
55 "inputs": [ 0 ],
56 "outputs": [ 1 ],
57 "builtin_options_type": "SpaceToDepthOptions",
58 "builtin_options": {
59 "block_size": 2
60 },
61 "custom_options_format": "FLEXBUFFERS"
62 }
63 ],
64 } ],
65 "buffers" : [
66 { },
67 { },
68 ]
69 }
70 )";
71 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
72 }
73};
74
75struct SimpleSpaceToDepthFixture : public SpaceToDepthFixture
76{
77 SimpleSpaceToDepthFixture() : SpaceToDepthFixture("[ 1, 2, 2, 1 ]", "[ 1, 1, 1, 4 ]") {}
78};
79
80TEST_CASE_FIXTURE(SimpleSpaceToDepthFixture, "ParseSpaceToDepth")
81{
82 RunTest<4, armnn::DataType::Float32>
83 (0,
84 {{ "inputTensor", { 1.f, 2.f, 3.f, 4.f }}},
85 {{ "outputTensor", { 1.f, 2.f, 3.f, 4.f }}} );
86}
87
88}