blob: d437ac8c7f661ea6a01e276b72fd31c63b8d3730 [file] [log] [blame]
Aron Virginas-Tarc949ab52019-10-14 16:43:13 +01001//
2// Copyright © 2019 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
Aron Virginas-Tarc949ab52019-10-14 16:43:13 +01008
Sadik Armagan1625efc2021-06-10 18:24:34 +01009TEST_SUITE("Deserializer_LogSoftmax")
10{
Aron Virginas-Tarc949ab52019-10-14 16:43:13 +010011struct LogSoftmaxFixture : public ParserFlatbuffersSerializeFixture
12{
13 explicit LogSoftmaxFixture(const std::string &shape,
14 const std::string &beta,
15 const std::string &axis,
16 const std::string &dataType)
17 {
18 m_JsonString = R"(
19 {
20 inputIds: [0],
21 outputIds: [2],
22 layers: [
23 {
24 layer_type: "InputLayer",
25 layer: {
26 base: {
27 layerBindingId: 0,
28 base: {
29 index: 0,
30 layerName: "InputLayer",
31 layerType: "Input",
32 inputSlots: [{
33 index: 0,
34 connection: { sourceLayerIndex:0, outputSlotIndex:0 },
35 }],
36 outputSlots: [{
37 index: 0,
38 tensorInfo: {
39 dimensions: )" + shape + R"(,
40 dataType: ")" + dataType + R"(",
41 quantizationScale: 0.5,
42 quantizationOffset: 0
43 },
44 }]
45 },
46 }
47 },
48 },
49 {
50 layer_type: "LogSoftmaxLayer",
51 layer : {
52 base: {
53 index:1,
54 layerName: "LogSoftmaxLayer",
55 layerType: "LogSoftmax",
56 inputSlots: [{
57 index: 0,
58 connection: { sourceLayerIndex:0, outputSlotIndex:0 },
59 }],
60 outputSlots: [{
61 index: 0,
62 tensorInfo: {
63 dimensions: )" + shape + R"(,
64 dataType: ")" + dataType + R"("
65 },
66 }],
67 },
68 descriptor: {
69 beta: ")" + beta + R"(",
70 axis: )" + axis + R"(
71 },
72 },
73 },
74 {
75 layer_type: "OutputLayer",
76 layer: {
77 base:{
78 layerBindingId: 0,
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: )" + shape + R"(,
91 dataType: ")" + dataType + R"("
92 },
93 }],
94 }
95 }},
96 }]
97 })";
98 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
99 }
100};
101
102struct LogSoftmaxFloat32Fixture : LogSoftmaxFixture
103{
104 LogSoftmaxFloat32Fixture() :
105 LogSoftmaxFixture("[ 1, 1, 2, 4 ]", // inputShape
106 "1.0", // beta
107 "3", // axis
108 "Float32") // dataType
109 {}
110};
111
Sadik Armagan1625efc2021-06-10 18:24:34 +0100112TEST_CASE_FIXTURE(LogSoftmaxFloat32Fixture, "LogSoftmaxFloat32")
Aron Virginas-Tarc949ab52019-10-14 16:43:13 +0100113{
114 RunTest<4, armnn::DataType::Float32>(
115 0,
116 {
117 0.f, -6.f, 2.f, 4.f,
118 3.f, -2.f, 10.f, 1.f
119 },
120 {
121 -4.14297f, -10.14297f, -2.14297f, -0.14297f,
122 -7.00104f, -12.00104f, -0.00105f, -9.00104f
123 });
124}
125
Sadik Armagan1625efc2021-06-10 18:24:34 +0100126}