ArmNN
 21.02
Maximum.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 MaximumFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
13 {
14  MaximumFixture(const armnn::TensorShape& inputShape0, const armnn::TensorShape& inputShape1)
15  {
16  m_Prototext = R"(
17 node {
18  name: "input0"
19  op: "Placeholder"
20  attr {
21  key: "dtype"
22  value {
23  type: DT_FLOAT
24  }
25  }
26  attr {
27  key: "shape"
28  value {
29  shape {
30  }
31  }
32  }
33 }
34 node {
35  name: "input1"
36  op: "Placeholder"
37  attr {
38  key: "dtype"
39  value {
40  type: DT_FLOAT
41  }
42  }
43  attr {
44  key: "shape"
45  value {
46  shape {
47  }
48  }
49  }
50 }
51 node {
52  name: "output"
53  op: "Maximum"
54  input: "input0"
55  input: "input1"
56  attr {
57  key: "T"
58  value {
59  type: DT_FLOAT
60  }
61  }
62 }
63  )";
64 
65  Setup({ { "input0", inputShape0 },
66  { "input1", inputShape1 } },
67  { "output" });
68  }
69 };
70 
71 struct MaximumFixture4D4D : public MaximumFixture
72 {
73  MaximumFixture4D4D() : MaximumFixture({ 1, 2, 2, 3 }, { 1, 2, 2, 3 }) {}
74 };
75 
76 BOOST_FIXTURE_TEST_CASE(ParseMaximum4D4D, MaximumFixture4D4D)
77 {
78  RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
79  3.0f, 4.0f, 5.0f,
80  6.0f, 7.0f, 8.0f,
81  9.0f, 10.0f, 11.0f } },
82  { "input1", { 5.0f, 1.0f, 3.0f,
83  4.0f, 5.5f, 1.0f,
84  2.0f, 17.0f, 18.0f,
85  19.0f, 1.0f, 3.0f } } },
86  { { "output", { 5.0f, 1.0f, 3.0f,
87  4.0f, 5.5f, 5.0f,
88  6.0f, 17.0f, 18.0f,
89  19.0f, 10.0f, 11.0f } } });
90 }
91 
92 struct MaximumBroadcastFixture4D4D : public MaximumFixture
93 {
94  MaximumBroadcastFixture4D4D() : MaximumFixture({ 1, 1, 2, 1 }, { 1, 2, 1, 3 }) {}
95 };
96 
97 BOOST_FIXTURE_TEST_CASE(ParseMaximumBroadcast4D4D, MaximumBroadcastFixture4D4D)
98 {
99  RunTest<4>({ { "input0", { 2.0f, 4.0f } },
100  { "input1", { 1.0f, 2.0f, 3.0f,
101  4.0f, 5.0f, 6.0f } } },
102  { { "output", { 2.0f, 2.0f, 3.0f,
103  4.0f, 4.0f, 4.0f,
104  4.0f, 5.0f, 6.0f,
105  4.0f, 5.0f, 6.0f } } });
106 }
107 
108 struct MaximumBroadcastFixture4D1D : public MaximumFixture
109 {
110  MaximumBroadcastFixture4D1D() : MaximumFixture({ 1, 2, 2, 3 }, { 1 }) {}
111 };
112 
113 BOOST_FIXTURE_TEST_CASE(ParseMaximumBroadcast4D1D, MaximumBroadcastFixture4D1D)
114 {
115  RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
116  3.0f, 4.0f, 5.0f,
117  6.0f, 7.0f, 8.0f,
118  9.0f, 10.0f, 11.0f } },
119  { "input1", { 5.0f } } },
120  { { "output", { 5.0f, 5.0f, 5.0f,
121  5.0f, 5.0f, 5.0f,
122  6.0f, 7.0f, 8.0f,
123  9.0f, 10.0f, 11.0f } } });
124 }
125 
126 struct MaximumBroadcastFixture1D4D : public MaximumFixture
127 {
128  MaximumBroadcastFixture1D4D() : MaximumFixture({ 1 }, { 1, 2, 2, 3 }) {}
129 };
130 
131 BOOST_FIXTURE_TEST_CASE(ParseMaximumBroadcast1D4D, MaximumBroadcastFixture1D4D)
132 {
133  RunTest<4>({ { "input0", { 3.0f } },
134  { "input1", { 0.0f, 1.0f, 2.0f,
135  3.0f, 4.0f, 5.0f,
136  6.0f, 7.0f, 8.0f,
137  9.0f, 10.0f, 11.0f } } },
138  { { "output", { 3.0f, 3.0f, 3.0f,
139  3.0f, 4.0f, 5.0f,
140  6.0f, 7.0f, 8.0f,
141  9.0f, 10.0f, 11.0f } } });
142 }
143 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(ParseMaximum4D4D, MaximumFixture4D4D)
Definition: Maximum.cpp:93
BOOST_AUTO_TEST_SUITE_END()