aboutsummaryrefslogtreecommitdiff
path: root/src/armnnCaffeParser/test/TestInPlace.cpp
blob: 2495e2182e6d339c576852a9f46d35430aa31f88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include <boost/test/unit_test.hpp>
#include "armnnCaffeParser/ICaffeParser.hpp"
#include "ParserPrototxtFixture.hpp"

BOOST_AUTO_TEST_SUITE(CaffeParser)

// The pooling layer should take its input from the relu, not the add directly.
struct InPlaceFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser>
{
    InPlaceFixture()
    {
        m_Prototext = R"(
name: "InPlace"
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 1 dim: 1 dim: 1 dim: 1 } }
}
layer {
    bottom: "data"
    bottom: "data"
    top: "add"
    name: "add"
    type: "Eltwise"
}
layer {
  name: "relu"
  type: "ReLU"
  bottom: "add"
  top: "relu"
  phase: TEST
}
layer {
  name: "pool"
  type: "Pooling"
  bottom: "relu"
  top: "pool"
  phase: TEST
  pooling_param {
    pool: MAX
    kernel_size: 1
    stride: 1
  }
}
        )";
        SetupSingleInputSingleOutput("data", "pool");
    }
};

BOOST_FIXTURE_TEST_CASE(ParseInPlace, InPlaceFixture)
{
    RunTest<1>({ -1.0f }, { 0.0f });
}

// The requested output of the network is a layer which has an activation attached.
// The output of the network should therefore actually be the activation layer.
struct InPlaceOutputFixture : public armnnUtils::ParserPrototxtFixture<armnnCaffeParser::ICaffeParser>
{
    InPlaceOutputFixture()
    {
        m_Prototext = R"(
name: "InPlace"
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 1 dim: 1 dim: 1 dim: 1 } }
}
layer {
    bottom: "data"
    bottom: "data"
    top: "add"
    name: "add"
    type: "Eltwise"
}
layer {
  name: "relu"
  type: "ReLU"
  bottom: "add"
  top: "add"
  phase: TEST
}
        )";
        SetupSingleInputSingleOutput("data", "add");
    }
};

BOOST_FIXTURE_TEST_CASE(InPlaceOutput, InPlaceOutputFixture)
{
    RunTest<1>({ -1.0f }, { 0.0f });
}

BOOST_AUTO_TEST_SUITE_END()