blob: a7c2bfe3e1218dec0e81dc09ce9f17bb7f077673 [file] [log] [blame]
surmeh01bceff2f2018-03-29 16:29:27 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// See LICENSE file in the project root for full license information.
4//
5
6#include <boost/test/unit_test.hpp>
7#include "armnnTfParser/ITfParser.hpp"
8#include "ParserPrototxtFixture.hpp"
9
10BOOST_AUTO_TEST_SUITE(TensorflowParser)
11
12
13struct LocalResponseNormalizationBaseFixture : public ParserPrototxtFixture<armnnTfParser::ITfParser>
14{
15 explicit LocalResponseNormalizationBaseFixture(float alpha, float beta, float bias)
16 {
17 std::string alphaString = std::to_string(alpha);
18 std::string betaString = std::to_string(beta);
19 std::string biasString = std::to_string(bias);
20
21 m_Prototext = "node {"
22 " name: \"Placeholder\""
23 " op: \"Placeholder\""
24 " attr {"
25 " key: \"dtype\""
26 " value {"
27 " type: DT_FLOAT"
28 " }"
29 " }"
30 " attr {"
31 " key: \"shape\""
32 " value {"
33 " shape {"
34 " unknown_rank: true"
35 " }"
36 " }"
37 " }"
38 "}"
39 "node {"
40 " name: \"LRN\""
41 " op: \"LRN\""
42 " input: \"Placeholder\""
43 " attr {"
44 " key: \"T\""
45 " value {"
46 " type: DT_FLOAT"
47 " }"
48 " }"
49 " attr {"
50 " key: \"alpha\""
51 " value {"
52 " f: ";
53 m_Prototext.append(alphaString);
54 m_Prototext.append("\n"
55 " }"
56 " }"
57 " attr {"
58 " key: \"beta\""
59 " value {"
60 " f: ");
61 m_Prototext.append(betaString);
62 m_Prototext.append("\n"
63 " }"
64 " }"
65 " attr {"
66 " key: \"bias\""
67 " value {"
68 " f: ");
69 m_Prototext.append(biasString);
70 m_Prototext.append("\n"
71 " }"
72 " }"
73 " attr {"
74 " key: \"depth_radius\""
75 " value {"
76 " i: 1"
77 " }"
78 " }"
79 "}");
80 }
81};
82
83
84struct LocalResponseNormalizationFixtureSimple : public LocalResponseNormalizationBaseFixture
85{
86 explicit LocalResponseNormalizationFixtureSimple()
87 : LocalResponseNormalizationBaseFixture(1.0f, 1.0f, 1.0f)
88 {
89 SetupSingleInputSingleOutput({ 2, 2, 2, 1 }, "Placeholder", "LRN");
90 }
91};
92BOOST_FIXTURE_TEST_CASE(ParseSimpleLocalResponseNormalization, LocalResponseNormalizationFixtureSimple)
93{
94 RunTest<4>({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f },
95 { 0.5f, 0.4f, 0.3f, 0.23529412f, 0.1923077f, 0.16216217f, 0.14f, 0.12307692f });
96}
97
98
99struct LocalResponseNormalizationFixture : public LocalResponseNormalizationBaseFixture
100{
101 explicit LocalResponseNormalizationFixture()
102 : LocalResponseNormalizationBaseFixture(0.5f, 1.0f, 0.5f)
103 {
104 SetupSingleInputSingleOutput({1, 3, 3, 2}, "Placeholder", "LRN");
105 }
106};
107BOOST_FIXTURE_TEST_CASE(ParseLocalResponseNormalization, LocalResponseNormalizationFixture)
108{
109 RunTest<4>({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f,
110 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f,
111 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f},
112
113 {0.333333340f, 0.66666670f, 0.230769250f, 0.307692320f, 0.161290320f, 0.19354838f,
114 0.122807020f, 0.14035088f, 0.098901100f, 0.109890110f, 0.082706770f, 0.09022556f,
115 0.071038246f, 0.07650273f, 0.062240668f, 0.066390045f, 0.055374593f, 0.05863192f});
116}
117
118
119
120
121BOOST_AUTO_TEST_SUITE_END()