blob: 5a1984af9ab696d91d81167c9032fd339d7342e5 [file] [log] [blame]
Saoirse Stewart263829c2019-02-19 15:54:14 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Saoirse Stewart263829c2019-02-19 15:54:14 +00006#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
Saoirse Stewart263829c2019-02-19 15:54:14 +00008
9#include <string>
Saoirse Stewart263829c2019-02-19 15:54:14 +000010
Sadik Armagan1625efc2021-06-10 18:24:34 +010011TEST_SUITE("Deserializer_Reshape")
12{
Saoirse Stewart263829c2019-02-19 15:54:14 +000013struct ReshapeFixture : public ParserFlatbuffersSerializeFixture
14{
15 explicit ReshapeFixture(const std::string &inputShape,
16 const std::string &targetShape,
17 const std::string &outputShape,
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 layer_type: "ReshapeLayer",
48 layer: {
49 base: {
50 index: 1,
51 layerName: "ReshapeLayer",
52 layerType: "Reshape",
53 inputSlots: [{
54 index: 0,
55 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
56 }],
57 outputSlots: [ {
58 index: 0,
59 tensorInfo: {
60 dimensions: )" + inputShape + R"(,
61 dataType: )" + dataType + R"(
62
63 }}]},
64 descriptor: {
65 targetShape: )" + targetShape + R"(,
66 }
67
68 }},
69 {
70 layer_type: "OutputLayer",
71 layer: {
72 base:{
73 layerBindingId: 2,
74 base: {
75 index: 2,
76 layerName: "OutputLayer",
77 layerType: "Output",
78 inputSlots: [{
79 index: 0,
80 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
81 }],
82 outputSlots: [ {
83 index: 0,
84 tensorInfo: {
85 dimensions: )" + outputShape + R"(,
86 dataType: )" + dataType + R"(
87 },
88 }],
89 }}},
90 }]
91 }
92 )";
93 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
94 }
95};
96
97struct SimpleReshapeFixture : ReshapeFixture
98{
99 SimpleReshapeFixture() : ReshapeFixture("[ 1, 9 ]", "[ 3, 3 ]", "[ 3, 3 ]",
100 "QuantisedAsymm8") {}
101};
102
103struct SimpleReshapeFixture2 : ReshapeFixture
104{
105 SimpleReshapeFixture2() : ReshapeFixture("[ 2, 2, 1, 1 ]",
106 "[ 2, 2, 1, 1 ]",
107 "[ 2, 2, 1, 1 ]",
108 "Float32") {}
109};
110
Sadik Armagan1625efc2021-06-10 18:24:34 +0100111TEST_CASE_FIXTURE(SimpleReshapeFixture, "ReshapeQuantisedAsymm8")
Saoirse Stewart263829c2019-02-19 15:54:14 +0000112{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000113 RunTest<2, armnn::DataType::QAsymmU8>(0,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000114 { 1, 2, 3, 4, 5, 6, 7, 8, 9 },
115 { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
116}
117
Sadik Armagan1625efc2021-06-10 18:24:34 +0100118TEST_CASE_FIXTURE(SimpleReshapeFixture2, "ReshapeFloat32")
Saoirse Stewart263829c2019-02-19 15:54:14 +0000119{
120 RunTest<4, armnn::DataType::Float32>(0,
121 { 111, 85, 226, 3 },
122 { 111, 85, 226, 3 });
123}
124
125
Sadik Armagan1625efc2021-06-10 18:24:34 +0100126}