2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
6 #include <boost/test/unit_test.hpp>
7 #include "armnnTfParser/ITfParser.hpp"
8 #include "ParserPrototxtFixture.hpp"
10 BOOST_AUTO_TEST_SUITE(TensorflowParser)
13 struct ActivationFixture : public ParserPrototxtFixture<armnnTfParser::ITfParser>
15 explicit ActivationFixture(const char* activationFunction)
17 m_Prototext = "node {\n"
18 " name: \"Placeholder\"\n"
19 " op: \"Placeholder\"\n"
30 " unknown_rank: true\n"
37 m_Prototext.append(activationFunction);
38 m_Prototext.append("\"\n"
40 m_Prototext.append(activationFunction);
41 m_Prototext.append("\"\n"
42 " input: \"Placeholder\"\n"
51 SetupSingleInputSingleOutput({ 1, 7 }, "Placeholder", activationFunction);
56 struct ReLuFixture : ActivationFixture
58 ReLuFixture() : ActivationFixture("Relu") {}
60 BOOST_FIXTURE_TEST_CASE(ParseReLu, ReLuFixture)
62 RunTest<2>({ -1.0f, -0.5f, 1.25f, -3.0f, 0.0f, 0.5f, -0.75f },
63 { 0.0f, 0.0f, 1.25f, 0.0f, 0.0f, 0.5f, 0.0f });
67 struct ReLu6Fixture : ActivationFixture
69 ReLu6Fixture() : ActivationFixture("Relu6") {}
71 BOOST_FIXTURE_TEST_CASE(ParseReLu6, ReLu6Fixture)
73 RunTest<2>({ -1.0f, -0.5f, 7.25f, -3.0f, 0.0f, 0.5f, -0.75f },
74 { 0.0f, 0.0f, 6.0f, 0.0f, 0.0f, 0.5f, 0.0f });
78 struct SigmoidFixture : ActivationFixture
80 SigmoidFixture() : ActivationFixture("Sigmoid") {}
82 BOOST_FIXTURE_TEST_CASE(ParseSigmoid, SigmoidFixture)
84 RunTest<2>({ -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f },
85 { 0.4750208f, 0.45016602f, 0.42555749f, 0.40131235f, 0.52497917f, 0.54983395f, 0.57444251f });
89 struct SoftplusFixture : ActivationFixture
91 SoftplusFixture() : ActivationFixture("Softplus") {}
93 BOOST_FIXTURE_TEST_CASE(ParseSoftplus, SoftplusFixture)
95 RunTest<2>({ -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f },
96 { 0.64439666f, 0.59813893f, 0.55435526f, 0.51301527f, 0.74439669f, 0.7981388f, 0.85435522f });
100 struct TanhFixture : ActivationFixture
102 TanhFixture() : ActivationFixture("Tanh") {}
104 BOOST_FIXTURE_TEST_CASE(ParseTanh, TanhFixture)
106 RunTest<2>({ -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f },
107 { -0.09966799f, -0.19737528f, -0.29131261f, -0.379949f, 0.09966799f, 0.19737528f, 0.29131261f });
113 BOOST_AUTO_TEST_SUITE_END()