ArmNN
 21.02
TestInPlace.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include <boost/test/unit_test.hpp>
8 
9 BOOST_AUTO_TEST_SUITE(CaffeParser)
10 
11 // The pooling layer should take its input from the relu, not the add directly.
12 struct InPlaceFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser>
13 {
14  InPlaceFixture()
15  {
16  m_Prototext = R"(
17 name: "InPlace"
18 layer {
19  name: "data"
20  type: "Input"
21  top: "data"
22  input_param { shape: { dim: 1 dim: 1 dim: 1 dim: 1 } }
23 }
24 layer {
25  bottom: "data"
26  bottom: "data"
27  top: "add"
28  name: "add"
29  type: "Eltwise"
30 }
31 layer {
32  name: "relu"
33  type: "ReLU"
34  bottom: "add"
35  top: "relu"
36  phase: TEST
37 }
38 layer {
39  name: "pool"
40  type: "Pooling"
41  bottom: "relu"
42  top: "pool"
43  phase: TEST
44  pooling_param {
45  pool: MAX
46  kernel_size: 1
47  stride: 1
48  }
49 }
50  )";
51  SetupSingleInputSingleOutput("data", "pool");
52  }
53 };
54 
55 BOOST_FIXTURE_TEST_CASE(ParseInPlace, InPlaceFixture)
56 {
57  RunTest<1>({ -1.0f }, { 0.0f });
58 }
59 
60 // The requested output of the network is a layer which has an activation attached.
61 // The output of the network should therefore actually be the activation layer.
62 struct InPlaceOutputFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser>
63 {
64  InPlaceOutputFixture()
65  {
66  m_Prototext = R"(
67 name: "InPlace"
68 layer {
69  name: "data"
70  type: "Input"
71  top: "data"
72  input_param { shape: { dim: 1 dim: 1 dim: 1 dim: 1 } }
73 }
74 layer {
75  bottom: "data"
76  bottom: "data"
77  top: "add"
78  name: "add"
79  type: "Eltwise"
80 }
81 layer {
82  name: "relu"
83  type: "ReLU"
84  bottom: "add"
85  top: "add"
86  phase: TEST
87 }
88  )";
89  SetupSingleInputSingleOutput("data", "add");
90  }
91 };
92 
93 BOOST_FIXTURE_TEST_CASE(InPlaceOutput, InPlaceOutputFixture)
94 {
95  RunTest<1>({ -1.0f }, { 0.0f });
96 }
97 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(ParseInPlace, InPlaceFixture)
Definition: TestInPlace.cpp:55
BOOST_AUTO_TEST_SUITE_END()
void SetupSingleInputSingleOutput(const std::string &inputName, const std::string &outputName)
Parses and loads the network defined by the m_Prototext string.