blob: f951943ed53a0b859131f224bec7000814247833 [file] [log] [blame]
Sadik Armagan26868492021-01-22 14:25:31 +00001//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Sadik Armagan26868492021-01-22 14:25:31 +00006#include "ParserFlatbuffersFixture.hpp"
Sadik Armagan26868492021-01-22 14:25:31 +00007
Sadik Armagan26868492021-01-22 14:25:31 +00008
Sadik Armagan1625efc2021-06-10 18:24:34 +01009TEST_SUITE("TensorflowLiteParser_DepthToSpace")
10{
Sadik Armagan26868492021-01-22 14:25:31 +000011struct DepthToSpaceFixture : public ParserFlatbuffersFixture
12{
13 explicit DepthToSpaceFixture(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": "DepthToSpaceOptions",
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 SimpleDepthToSpaceFixture : public DepthToSpaceFixture
76{
77 SimpleDepthToSpaceFixture() : DepthToSpaceFixture("[ 1, 2, 2, 4 ]", "[ 1, 4, 4, 1 ]") {}
78};
79
Sadik Armagan1625efc2021-06-10 18:24:34 +010080TEST_CASE_FIXTURE(SimpleDepthToSpaceFixture, "ParseDepthToSpace")
Sadik Armagan26868492021-01-22 14:25:31 +000081{
82 RunTest<4, armnn::DataType::Float32>
83 (0,
84 {{ "inputTensor", { 1.f, 2.f, 3.f, 4.f,
85 5.f, 6.f, 7.f, 8.f,
86 9.f, 10.f, 11.f, 12.f,
87 13.f, 14.f, 15.f, 16.f }}},
88 {{ "outputTensor", { 1.f, 2.f, 5.f, 6.f,
89 3.f, 4.f, 7.f, 8.f,
90 9.f, 10.f, 13.f, 14.f,
91 11.f, 12.f, 15.f, 16.f }}});
92}
93
Sadik Armagan1625efc2021-06-10 18:24:34 +010094}