blob: 7b474e215d9456c67ed7b93ee1b6afddca5c6a9f [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
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +00006#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +00008
9#include <string>
10
Sadik Armagan1625efc2021-06-10 18:24:34 +010011TEST_SUITE("Deserializer_Permute")
12{
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +000013struct PermuteFixture : public ParserFlatbuffersSerializeFixture
14{
15 explicit PermuteFixture(const std::string &inputShape,
16 const std::string &dimMappings,
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 }
48 },
49 {
50 layer_type: "PermuteLayer",
51 layer: {
52 base: {
53 index: 1,
54 layerName: "PermuteLayer",
55 layerType: "Permute",
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 dimMappings: )" + dimMappings + R"(,
70 }
71 }
72 },
73 {
74 layer_type: "OutputLayer",
75 layer: {
76 base:{
77 layerBindingId: 2,
78 base: {
79 index: 2,
80 layerName: "OutputLayer",
81 layerType: "Output",
82 inputSlots: [{
83 index: 0,
84 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
85 }],
86 outputSlots: [{
87 index: 0,
88 tensorInfo: {
89 dimensions: )" + outputShape + R"(,
90 dataType: )" + dataType + R"(
91 },
92 }],
93 }
94 }
95 },
96 }
97 ]
98 }
99 )";
100 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
101 }
102};
103
104struct SimplePermute2DFixture : PermuteFixture
105{
106 SimplePermute2DFixture() : PermuteFixture("[ 2, 3 ]",
107 "[ 1, 0 ]",
108 "[ 3, 2 ]",
109 "QuantisedAsymm8") {}
110};
111
Sadik Armagan1625efc2021-06-10 18:24:34 +0100112TEST_CASE_FIXTURE(SimplePermute2DFixture, "SimplePermute2DQuantisedAsymm8")
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000113{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000114 RunTest<2, armnn::DataType::QAsymmU8>(0,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000115 { 1, 2, 3, 4, 5, 6 },
116 { 1, 4, 2, 5, 3, 6 });
117}
118
119struct SimplePermute4DFixture : PermuteFixture
120{
121 SimplePermute4DFixture() : PermuteFixture("[ 1, 2, 3, 4 ]",
122 "[ 3, 2, 1, 0 ]",
123 "[ 4, 3, 2, 1 ]",
124 "QuantisedAsymm8") {}
125};
126
Sadik Armagan1625efc2021-06-10 18:24:34 +0100127TEST_CASE_FIXTURE(SimplePermute4DFixture, "SimplePermute4DQuantisedAsymm8")
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000128{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000129 RunTest<4, armnn::DataType::QAsymmU8>(0,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000130 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
131 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 },
132 { 1, 13, 5, 17, 9, 21, 2, 14, 6, 18, 10, 22,
133 3, 15, 7, 19, 11, 23, 4, 16, 8, 20, 12, 24 });
134}
135
Sadik Armagan1625efc2021-06-10 18:24:34 +0100136}