ArmNN
 20.08
TestDependencies.cpp File Reference
#include <boost/test/unit_test.hpp>
#include "armnnTfParser/ITfParser.hpp"
#include "ParserPrototxtFixture.hpp"

Go to the source code of this file.

Functions

 BOOST_FIXTURE_TEST_CASE (RediscoveredDependencies, RediscoveredDependenciesFixture)
 
 BOOST_AUTO_TEST_CASE (SimpleCycle)
 
 BOOST_AUTO_TEST_CASE (SingleNodeCycle)
 
 BOOST_AUTO_TEST_CASE (ComplexCycle)
 
 BOOST_AUTO_TEST_CASE (InvalidInput)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( SimpleCycle  )

Definition at line 124 of file TestDependencies.cpp.

References ITfParser::Create().

125 {
126  const char* prototext = R"(
127 node {
128  name: "r1"
129  op: "Relu"
130  input: "r2"
131  attr {
132  key: "T"
133  value {
134  type: DT_FLOAT
135  }
136  }
137 }
138 node {
139  name: "r2"
140  op: "Relu"
141  input: "r1"
142  attr {
143  key: "T"
144  value {
145  type: DT_FLOAT
146  }
147  }
148 }
149  )";
151  BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "r2" }), armnn::ParseException);
152 }
std::unique_ptr< ITfParser, void(*)(ITfParser *parser)> ITfParserPtr
Definition: ITfParser.hpp:22
static ITfParserPtr Create()
Definition: TfParser.cpp:394

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( SingleNodeCycle  )

Definition at line 155 of file TestDependencies.cpp.

References ITfParser::Create().

156 {
157  const char* prototext = R"(
158 node {
159  name: "r1"
160  op: "Relu"
161  input: "r1"
162  attr {
163  key: "T"
164  value {
165  type: DT_FLOAT
166  }
167  }
168 }
169  )";
171  BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "r1" }), armnn::ParseException);
172 }
std::unique_ptr< ITfParser, void(*)(ITfParser *parser)> ITfParserPtr
Definition: ITfParser.hpp:22
static ITfParserPtr Create()
Definition: TfParser.cpp:394

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( ComplexCycle  )

Definition at line 185 of file TestDependencies.cpp.

References ITfParser::Create().

186 {
187  // Input = tf.placeholder(tf.float32, 1, "input")
188  // Add2 = tf.nn.relu(input, add1, "add2") // This line won't actually run in TF, because add1 is not yet defined
189  // Relu1 = tf.nn.relu(relu0, "relu1")
190  // Relu2 = tf.nn.relu(relu0, "relu2")
191  // Relu3 = tf.nn.relu(relu2, "relu3")
192  // Add1 = tf.add(relu1, relu3, "add1")
193  const char* prototext = R"(
194  node {
195  name: "input"
196  op: "Placeholder"
197  attr {
198  key: "dtype"
199  value {
200  type: DT_FLOAT
201  }
202  }
203  attr {
204  key: "shape"
205  value {
206  shape {
207  dim {
208  size: 1
209  }
210  }
211  }
212  }
213  }
214  node {
215  name: "add2"
216  op: "Add"
217  input: "input"
218  input: "add1"
219  attr {
220  key: "T"
221  value {
222  type: DT_FLOAT
223  }
224  }
225  }
226  node {
227  name: "relu1"
228  op: "Relu"
229  input: "add2"
230  attr {
231  key: "T"
232  value {
233  type: DT_FLOAT
234  }
235  }
236  }
237  node {
238  name: "relu2"
239  op: "Relu"
240  input: "add2"
241  attr {
242  key: "T"
243  value {
244  type: DT_FLOAT
245  }
246  }
247  }
248  node {
249  name: "relu3"
250  op: "Relu"
251  input: "relu2"
252  attr {
253  key: "T"
254  value {
255  type: DT_FLOAT
256  }
257  }
258  }
259  node {
260  name: "add1"
261  op: "Add"
262  input: "relu1"
263  input: "relu3"
264  attr {
265  key: "T"
266  value {
267  type: DT_FLOAT
268  }
269  }
270  }
271  )";
273  BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "add1" }), armnn::ParseException);
274 }
std::unique_ptr< ITfParser, void(*)(ITfParser *parser)> ITfParserPtr
Definition: ITfParser.hpp:22
static ITfParserPtr Create()
Definition: TfParser.cpp:394

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( InvalidInput  )

Definition at line 277 of file TestDependencies.cpp.

References BOOST_AUTO_TEST_SUITE_END(), and ITfParser::Create().

278 {
279  const char* prototext = R"(
280 node {
281  name: "r1"
282  op: "Relu"
283  input: "a-node-that-does-not-exist"
284  attr {
285  key: "T"
286  value {
287  type: DT_FLOAT
288  }
289  }
290 }
291  )";
293  BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "r1" }), armnn::ParseException);
294 }
std::unique_ptr< ITfParser, void(*)(ITfParser *parser)> ITfParserPtr
Definition: ITfParser.hpp:22
static ITfParserPtr Create()
Definition: TfParser.cpp:394

◆ BOOST_FIXTURE_TEST_CASE()

BOOST_FIXTURE_TEST_CASE ( RediscoveredDependencies  ,
RediscoveredDependenciesFixture   
)

Definition at line 117 of file TestDependencies.cpp.

118 {
119  RunTest<1>({1}, {2});
120 }