ArmNN
 20.11
Pad.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <boost/test/unit_test.hpp>
9 
10 BOOST_AUTO_TEST_SUITE(TensorflowParser)
11 
12 struct PadFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
13 {
14  PadFixture() {
15  m_Prototext = "node {\n"
16  " name: \"input\"\n"
17  " op: \"Placeholder\"\n"
18  " attr {\n"
19  " key: \"dtype\"\n"
20  " value {\n"
21  " type: DT_FLOAT\n"
22  " }\n"
23  " }\n"
24  " attr {\n"
25  " key: \"shape\"\n"
26  " value {\n"
27  " shape {\n"
28  " dim {\n"
29  " size: -1\n"
30  " }\n"
31  " dim {\n"
32  " size: 2\n"
33  " }\n"
34  " dim {\n"
35  " size: 2\n"
36  " }\n"
37  " dim {\n"
38  " size: 2\n"
39  " }\n"
40  " }\n"
41  " }\n"
42  " }\n"
43  "}\n"
44  "node {\n"
45  " name: \"Pad/paddings\"\n"
46  " op: \"Const\"\n"
47  " attr {\n"
48  " key: \"dtype\"\n"
49  " value {\n"
50  " type: DT_INT32\n"
51  " }\n"
52  " }\n"
53  " attr {\n"
54  " key: \"value\"\n"
55  " value {\n"
56  " tensor {\n"
57  " dtype: DT_INT32\n"
58  " tensor_shape {\n"
59  " dim {\n"
60  " size: 4\n"
61  " }\n"
62  " dim {\n"
63  " size: 2\n"
64  " }\n"
65  " }\n"
66  " tensor_content: \"\\000\\000\\000\\000\\000\\000\\000\\000"
67  "\\001\\000\\000\\000\\001\\000\\000\\000"
68  "\\001\\000\\000\\000\\001\\000\\000\\000"
69  "\\000\\000\\000\\000\\000\\000\\000\\000\"\n"
70  " }\n"
71  " }\n"
72  " }\n"
73  "}\n"
74  "node {\n"
75  " name: \"Pad\"\n"
76  " op: \"Pad\"\n"
77  " input: \"input\"\n"
78  " input: \"Pad/paddings\"\n"
79  " attr {\n"
80  " key: \"T\"\n"
81  " value {\n"
82  " type: DT_FLOAT\n"
83  " }\n"
84  " }\n"
85  " attr {\n"
86  " key: \"Tpaddings\"\n"
87  " value {\n"
88  " type: DT_INT32\n"
89  " }\n"
90  " }\n"
91  "}";
92 
93  SetupSingleInputSingleOutput({1, 2, 2, 2}, "input", "Pad");
94  }
95 };
96 
97 BOOST_FIXTURE_TEST_CASE(ParsePad, PadFixture)
98 {
99  RunTest<4>({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f },
100  { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
101  0.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 0.0f, 0.0f,
102  0.0f, 0.0f, 5.0f, 6.0f, 7.0f, 8.0f, 0.0f, 0.0f,
103  0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
104  });
105 }
106 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
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.
BOOST_FIXTURE_TEST_CASE(ParsePad, SimplePadFixture)
Definition: Pad.cpp:93