blob: 1d72b0f33f32d40c0dfc08fdd6cfd0060fc8919f [file] [log] [blame]
Sadik Armagan0c3ea5b2021-02-03 09:29:30 +00001//
2// Copyright © 2020 Samsung Electronics Co Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Sadik Armagan0c3ea5b2021-02-03 09:29:30 +00006#include "ParserFlatbuffersSerializeFixture.hpp"
7#include "../Deserializer.hpp"
8
9#include <string>
Sadik Armagan0c3ea5b2021-02-03 09:29:30 +000010
Sadik Armagan1625efc2021-06-10 18:24:34 +010011TEST_SUITE("Deserializer_ReduceSum")
12{
Sadik Armagan0c3ea5b2021-02-03 09:29:30 +000013struct ReduceSumFixture : public ParserFlatbuffersSerializeFixture
14{
15 explicit ReduceSumFixture(const std::string& inputShape,
16 const std::string& outputShape,
17 const std::string& axis,
18 const std::string& dataType)
19 {
20 m_JsonString = R"(
21 {
22 inputIds: [0],
23 outputIds: [2],
24 layers: [
25 {
26 layer_type: "InputLayer",
27 layer: {
28 base: {
29 layerBindingId: 0,
30 base: {
31 index: 0,
32 layerName: "InputLayer",
33 layerType: "Input",
34 inputSlots: [{
35 index: 0,
36 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
37 }],
38 outputSlots: [{
39 index: 0,
40 tensorInfo: {
41 dimensions: )" + inputShape + R"(,
42 dataType: )" + dataType + R"(
43 }
44 }]
45 }
46 }
47 }
48 },
49 {
50 layer_type: "ReduceLayer",
51 layer: {
52 base: {
53 index: 1,
54 layerName: "ReduceSumLayer",
55 layerType: "Reduce",
56 inputSlots: [{
57 index: 0,
58 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
59 }],
60 outputSlots: [{
61 index: 0,
62 tensorInfo: {
63 dimensions: )" + outputShape + R"(,
64 dataType: )" + dataType + R"(
65 }
66 }]
67 },
68 descriptor: {
69 axis: )" + axis + R"(,
70 keepDims: true,
71 reduceOperation: Sum
72 }
73 }
74 },
75 {
76 layer_type: "OutputLayer",
77 layer: {
78 base:{
79 layerBindingId: 2,
80 base: {
81 index: 2,
82 layerName: "OutputLayer",
83 layerType: "Output",
84 inputSlots: [{
85 index: 0,
86 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
87 }],
88 outputSlots: [{
89 index: 0,
90 tensorInfo: {
91 dimensions: )" + outputShape + R"(,
92 dataType: )" + dataType + R"(
93 },
94 }],
95 }
96 }
97 },
98 }
99 ]
100 }
101 )";
102 Setup();
103 }
104};
105
106struct SimpleReduceSumFixture : ReduceSumFixture
107{
108 SimpleReduceSumFixture()
109 : ReduceSumFixture("[ 1, 1, 3, 2 ]", // inputShape
110 "[ 1, 1, 1, 2 ]", // outputShape
111 "[ 2 ]", // axis
112 "Float32") // dataType
113 {}
114};
115
Sadik Armagan1625efc2021-06-10 18:24:34 +0100116TEST_CASE_FIXTURE(SimpleReduceSumFixture, "SimpleReduceSum")
Sadik Armagan0c3ea5b2021-02-03 09:29:30 +0000117{
118 RunTest<4, armnn::DataType::Float32>(
119 0,
120 {{"InputLayer", { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f }}},
121 {{"OutputLayer", { 6.0f, 6.0f }}});
122}
123
Sadik Armagan1625efc2021-06-10 18:24:34 +0100124}