blob: 2495e2182e6d339c576852a9f46d35430aa31f88 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
telsoa014fcda012018-03-09 14:13:49 +00002// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#include <boost/test/unit_test.hpp>
6#include "armnnCaffeParser/ICaffeParser.hpp"
7#include "ParserPrototxtFixture.hpp"
8
9BOOST_AUTO_TEST_SUITE(CaffeParser)
10
11// The pooling layer should take its input from the relu, not the add directly.
telsoa01c577f2c2018-08-31 09:22:23 +010012struct InPlaceFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser>
telsoa014fcda012018-03-09 14:13:49 +000013{
14 InPlaceFixture()
15 {
16 m_Prototext = R"(
17name: "InPlace"
18layer {
19 name: "data"
20 type: "Input"
21 top: "data"
22 input_param { shape: { dim: 1 dim: 1 dim: 1 dim: 1 } }
23}
24layer {
25 bottom: "data"
26 bottom: "data"
27 top: "add"
28 name: "add"
29 type: "Eltwise"
30}
31layer {
32 name: "relu"
33 type: "ReLU"
34 bottom: "add"
35 top: "relu"
36 phase: TEST
37}
38layer {
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
55BOOST_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.
telsoa01c577f2c2018-08-31 09:22:23 +010062struct InPlaceOutputFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser>
telsoa014fcda012018-03-09 14:13:49 +000063{
64 InPlaceOutputFixture()
65 {
66 m_Prototext = R"(
67name: "InPlace"
68layer {
69 name: "data"
70 type: "Input"
71 top: "data"
72 input_param { shape: { dim: 1 dim: 1 dim: 1 dim: 1 } }
73}
74layer {
75 bottom: "data"
76 bottom: "data"
77 top: "add"
78 name: "add"
79 type: "Eltwise"
80}
81layer {
82 name: "relu"
83 type: "ReLU"
84 bottom: "add"
85 top: "add"
86 phase: TEST
87}
88 )";
89 SetupSingleInputSingleOutput("data", "add");
90 }
91};
92
93BOOST_FIXTURE_TEST_CASE(InPlaceOutput, InPlaceOutputFixture)
94{
95 RunTest<1>({ -1.0f }, { 0.0f });
96}
97
98BOOST_AUTO_TEST_SUITE_END()