ArmNN
 21.02
CreateNetwork.cpp File Reference
#include <boost/test/unit_test.hpp>
#include "armnnOnnxParser/IOnnxParser.hpp"
#include "google/protobuf/stubs/logging.h"

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (CreateNetworkFromString)
 
 BOOST_AUTO_TEST_CASE (CreateNetworkFromStringWithNullptr)
 
 BOOST_AUTO_TEST_CASE (CreateNetworkWithInvalidString)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( CreateNetworkFromString  )

Definition at line 12 of file CreateNetwork.cpp.

References IOnnxParser::Create().

13 {
14  std::string TestModel = R"(
15  ir_version: 3
16  producer_name: "CNTK "
17  producer_version: "2.5.1 "
18  domain: "ai.cntk "
19  model_version: 1
20  graph {
21  name: "CNTKGraph "
22  output {
23  name: "Output"
24  type {
25  tensor_type {
26  elem_type: 1
27  shape {
28  dim {
29  dim_value: 1
30  }
31  dim {
32  dim_value: 10
33  }
34  }
35  }
36  }
37  }
38  }
39  opset_import {
40  version: 7
41  })";
42 
44 
45  armnn::INetworkPtr network = parser->CreateNetworkFromString(TestModel.c_str());
46  BOOST_TEST(network.get());
47 }
static IOnnxParserPtr Create()
Definition: OnnxParser.cpp:36
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:173
std::unique_ptr< IOnnxParser, void(*)(IOnnxParser *parser)> IOnnxParserPtr
Definition: IOnnxParser.hpp:21

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( CreateNetworkFromStringWithNullptr  )

Definition at line 49 of file CreateNetwork.cpp.

References IOnnxParser::Create().

50 {
52  BOOST_CHECK_THROW(parser->CreateNetworkFromString(""), armnn::InvalidArgumentException );
53 }
static IOnnxParserPtr Create()
Definition: OnnxParser.cpp:36
std::unique_ptr< IOnnxParser, void(*)(IOnnxParser *parser)> IOnnxParserPtr
Definition: IOnnxParser.hpp:21

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( CreateNetworkWithInvalidString  )

Definition at line 55 of file CreateNetwork.cpp.

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

56 {
57  auto silencer = google::protobuf::LogSilencer(); //get rid of errors from protobuf
59  BOOST_CHECK_THROW(parser->CreateNetworkFromString( "I'm not a model so I should raise an error" ),
61 }
static IOnnxParserPtr Create()
Definition: OnnxParser.cpp:36
std::unique_ptr< IOnnxParser, void(*)(IOnnxParser *parser)> IOnnxParserPtr
Definition: IOnnxParser.hpp:21