blob: c771a232b0b7bdf53d59b0f732c577bb2ee9676f [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
6#include <boost/test/unit_test.hpp>
7#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00008#include <armnnDeserializer/IDeserializer.hpp>
Saoirse Stewart263829c2019-02-19 15:54:14 +00009
10#include <string>
Saoirse Stewart263829c2019-02-19 15:54:14 +000011
Derek Lamberti0028d1b2019-02-20 13:57:42 +000012BOOST_AUTO_TEST_SUITE(Deserializer)
Saoirse Stewart263829c2019-02-19 15:54:14 +000013
14struct ReshapeFixture : public ParserFlatbuffersSerializeFixture
15{
16 explicit ReshapeFixture(const std::string &inputShape,
17 const std::string &targetShape,
18 const std::string &outputShape,
19 const std::string &dataType)
20 {
21 m_JsonString = R"(
22 {
23 inputIds: [0],
24 outputIds: [2],
25 layers: [
26 {
27 layer_type: "InputLayer",
28 layer: {
29 base: {
30 layerBindingId: 0,
31 base: {
32 index: 0,
33 layerName: "InputLayer",
34 layerType: "Input",
35 inputSlots: [{
36 index: 0,
37 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
38 }],
39 outputSlots: [ {
40 index: 0,
41 tensorInfo: {
42 dimensions: )" + inputShape + R"(,
43 dataType: )" + dataType + R"(
44 }}]
45 }
46 }}},
47 {
48 layer_type: "ReshapeLayer",
49 layer: {
50 base: {
51 index: 1,
52 layerName: "ReshapeLayer",
53 layerType: "Reshape",
54 inputSlots: [{
55 index: 0,
56 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
57 }],
58 outputSlots: [ {
59 index: 0,
60 tensorInfo: {
61 dimensions: )" + inputShape + R"(,
62 dataType: )" + dataType + R"(
63
64 }}]},
65 descriptor: {
66 targetShape: )" + targetShape + R"(,
67 }
68
69 }},
70 {
71 layer_type: "OutputLayer",
72 layer: {
73 base:{
74 layerBindingId: 2,
75 base: {
76 index: 2,
77 layerName: "OutputLayer",
78 layerType: "Output",
79 inputSlots: [{
80 index: 0,
81 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
82 }],
83 outputSlots: [ {
84 index: 0,
85 tensorInfo: {
86 dimensions: )" + outputShape + R"(,
87 dataType: )" + dataType + R"(
88 },
89 }],
90 }}},
91 }]
92 }
93 )";
94 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
95 }
96};
97
98struct SimpleReshapeFixture : ReshapeFixture
99{
100 SimpleReshapeFixture() : ReshapeFixture("[ 1, 9 ]", "[ 3, 3 ]", "[ 3, 3 ]",
101 "QuantisedAsymm8") {}
102};
103
104struct SimpleReshapeFixture2 : ReshapeFixture
105{
106 SimpleReshapeFixture2() : ReshapeFixture("[ 2, 2, 1, 1 ]",
107 "[ 2, 2, 1, 1 ]",
108 "[ 2, 2, 1, 1 ]",
109 "Float32") {}
110};
111
112BOOST_FIXTURE_TEST_CASE(ReshapeQuantisedAsymm8, SimpleReshapeFixture)
113{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000114 RunTest<2, armnn::DataType::QAsymmU8>(0,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000115 { 1, 2, 3, 4, 5, 6, 7, 8, 9 },
116 { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
117}
118
119BOOST_FIXTURE_TEST_CASE(ReshapeFloat32, SimpleReshapeFixture2)
120{
121 RunTest<4, armnn::DataType::Float32>(0,
122 { 111, 85, 226, 3 },
123 { 111, 85, 226, 3 });
124}
125
126
127BOOST_AUTO_TEST_SUITE_END()