telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #include <boost/test/unit_test.hpp> |
| 6 | #include "armnnCaffeParser/ICaffeParser.hpp" |
| 7 | #include "ParserPrototxtFixture.hpp" |
| 8 | |
| 9 | BOOST_AUTO_TEST_SUITE(CaffeParser) |
| 10 | |
| 11 | // The pooling layer should take its input from the relu, not the add directly. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 12 | struct InPlaceFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 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. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 62 | struct InPlaceOutputFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 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 | |
| 98 | BOOST_AUTO_TEST_SUITE_END() |