blob: 8cfe25baca3d034618c8a69923cfdf687f1461b0 [file] [log] [blame]
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +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>
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +00009
10#include <string>
11
12BOOST_AUTO_TEST_SUITE(Deserializer)
13
14struct PermuteFixture : public ParserFlatbuffersSerializeFixture
15{
16 explicit PermuteFixture(const std::string &inputShape,
17 const std::string &dimMappings,
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 }
49 },
50 {
51 layer_type: "PermuteLayer",
52 layer: {
53 base: {
54 index: 1,
55 layerName: "PermuteLayer",
56 layerType: "Permute",
57 inputSlots: [{
58 index: 0,
59 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
60 }],
61 outputSlots: [{
62 index: 0,
63 tensorInfo: {
64 dimensions: )" + outputShape + R"(,
65 dataType: )" + dataType + R"(
66 }
67 }]
68 },
69 descriptor: {
70 dimMappings: )" + dimMappings + R"(,
71 }
72 }
73 },
74 {
75 layer_type: "OutputLayer",
76 layer: {
77 base:{
78 layerBindingId: 2,
79 base: {
80 index: 2,
81 layerName: "OutputLayer",
82 layerType: "Output",
83 inputSlots: [{
84 index: 0,
85 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
86 }],
87 outputSlots: [{
88 index: 0,
89 tensorInfo: {
90 dimensions: )" + outputShape + R"(,
91 dataType: )" + dataType + R"(
92 },
93 }],
94 }
95 }
96 },
97 }
98 ]
99 }
100 )";
101 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
102 }
103};
104
105struct SimplePermute2DFixture : PermuteFixture
106{
107 SimplePermute2DFixture() : PermuteFixture("[ 2, 3 ]",
108 "[ 1, 0 ]",
109 "[ 3, 2 ]",
110 "QuantisedAsymm8") {}
111};
112
113BOOST_FIXTURE_TEST_CASE(SimplePermute2DQuantisedAsymm8, SimplePermute2DFixture)
114{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000115 RunTest<2, armnn::DataType::QAsymmU8>(0,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000116 { 1, 2, 3, 4, 5, 6 },
117 { 1, 4, 2, 5, 3, 6 });
118}
119
120struct SimplePermute4DFixture : PermuteFixture
121{
122 SimplePermute4DFixture() : PermuteFixture("[ 1, 2, 3, 4 ]",
123 "[ 3, 2, 1, 0 ]",
124 "[ 4, 3, 2, 1 ]",
125 "QuantisedAsymm8") {}
126};
127
128BOOST_FIXTURE_TEST_CASE(SimplePermute4DQuantisedAsymm8, SimplePermute4DFixture)
129{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000130 RunTest<4, armnn::DataType::QAsymmU8>(0,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000131 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
132 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 },
133 { 1, 13, 5, 17, 9, 21, 2, 14, 6, 18, 10, 22,
134 3, 15, 7, 19, 11, 23, 4, 16, 8, 20, 12, 24 });
135}
136
137BOOST_AUTO_TEST_SUITE_END()