aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfParser/test/Pooling.cpp
blob: 36ffa47def4ab24232fea6d5e3cfede85f910fe9 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include <boost/test/unit_test.hpp>
#include "armnnTfParser/ITfParser.hpp"
#include "ParserPrototxtFixture.hpp"

BOOST_AUTO_TEST_SUITE(TensorflowParser)


struct Pooling2dFixture : public ParserPrototxtFixture<armnnTfParser::ITfParser>
{
    explicit Pooling2dFixture(const char* poolingtype)
    {
        m_Prototext =  "node {\n"
            "  name: \"Placeholder\"\n"
            "  op: \"Placeholder\"\n"
            "  attr {\n"
            "    key: \"dtype\"\n"
            "    value {\n"
            "      type: DT_FLOAT\n"
            "    }\n"
            "  }\n"
            "  attr {\n"
            "    key: \"value\"\n"
            "    value {\n"
            "      tensor {\n"
            "        dtype: DT_FLOAT\n"
            "        tensor_shape {\n"
            "        }\n"
            "      }\n"
            "    }\n"
            "   }\n"
            "  }\n"
            "node {\n"
            "  name: \"";
        m_Prototext.append(poolingtype);
        m_Prototext.append("\"\n"
                               "  op: \"");
        m_Prototext.append(poolingtype);
        m_Prototext.append("\"\n"
                               "  input: \"Placeholder\"\n"
                               "  attr {\n"
                               "    key: \"T\"\n"
                               "    value {\n"
                               "      type: DT_FLOAT\n"
                               "    }\n"
                               "  }\n"
                               "  attr {\n"
                               "    key: \"data_format\"\n"
                               "    value {\n"
                               "      s: \"NHWC\"\n"
                               "    }\n"
                               "  }\n"
                               "  attr {\n"
                               "    key: \"ksize\"\n"
                               "    value {\n"
                               "      list {\n"
                               "        i: 1\n"
                               "        i: 2\n"
                               "        i: 2\n"
                               "        i: 1\n"
                               "      }\n"
                               "    }\n"
                               "  }\n"
                               "  attr {\n"
                               "    key: \"padding\"\n"
                               "    value {\n"
                               "      s: \"VALID\"\n"
                               "    }\n"
                               "  }\n"
                               "  attr {\n"
                               "    key: \"strides\"\n"
                               "    value {\n"
                               "      list {\n"
                               "        i: 1\n"
                               "        i: 1\n"
                               "        i: 1\n"
                               "        i: 1\n"
                               "      }\n"
                               "    }\n"
                               "  }\n"
                               "}\n");

        SetupSingleInputSingleOutput({ 1, 2, 2, 1 }, "Placeholder", poolingtype);
    }
};


struct MaxPoolFixture : Pooling2dFixture
{
    MaxPoolFixture() : Pooling2dFixture("MaxPool") {}
};
BOOST_FIXTURE_TEST_CASE(ParseMaxPool, MaxPoolFixture)
{
    RunTest<4>({1.0f, 2.0f, 3.0f, -4.0f}, {3.0f});
}


struct AvgPoolFixture : Pooling2dFixture
{
    AvgPoolFixture() : Pooling2dFixture("AvgPool") {}
};
BOOST_FIXTURE_TEST_CASE(ParseAvgPool, AvgPoolFixture)
{
    RunTest<4>({1.0f, 2.0f, 3.0f, 4.0f}, {2.5f});
}


BOOST_AUTO_TEST_SUITE_END()