blob: bb03ecd1a517369db0e9474a68a001ae757ae363 [file] [log] [blame]
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +01006#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +01008
Sadik Armagan1625efc2021-06-10 18:24:34 +01009#include <doctest/doctest.h>
10
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +010011#include <string>
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +010012
Sadik Armagan1625efc2021-06-10 18:24:34 +010013TEST_SUITE("Deserializer_Abs")
14{
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +010015 struct AbsFixture : public ParserFlatbuffersSerializeFixture
16 {
17 explicit AbsFixture(const std::string &inputShape,
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: "AbsLayer",
52 layer: {
53 base: {
54 index: 1,
55 layerName: "AbsLayer",
56 layerType: "Abs",
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
70 }
71 },
72 {
73 layer_type: "OutputLayer",
74 layer: {
75 base:{
76 layerBindingId: 2,
77 base: {
78 index: 2,
79 layerName: "OutputLayer",
80 layerType: "Output",
81 inputSlots: [{
82 index: 0,
83 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
84 }],
85 outputSlots: [{
86 index: 0,
87 tensorInfo: {
88 dimensions: )" + outputShape + R"(,
89 dataType: )" + dataType + R"(
90 },
91 }],
92 }
93 }
94 },
95 }
96 ]
97 }
98 )";
99 Setup();
100 }
101 };
102
103 struct SimpleAbsFixture : AbsFixture
104 {
105 SimpleAbsFixture()
106 : AbsFixture("[ 1, 2, 2, 2 ]", // inputShape
107 "[ 1, 2, 2, 2 ]", // outputShape
108 "Float32") // dataType
109 {}
110 };
111
Sadik Armagan1625efc2021-06-10 18:24:34 +0100112 TEST_CASE_FIXTURE(SimpleAbsFixture, "SimpleAbsTest")
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +0100113 {
114 RunTest<4, armnn::DataType::Float32>(
115 0,
116 {{"InputLayer", { -100.0f, -50.5f, -25.9999f, -0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}},
Francis Murtaghe8ac1332020-07-30 18:03:40 +0100117 {{"OutputLayer", { 100.0f, 50.5f, 25.9999f, 0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}});
FinnWilliamsArm4ffcc8f2019-09-05 14:34:20 +0100118 }
119
Sadik Armagan1625efc2021-06-10 18:24:34 +0100120}