ArmNN
 22.05.01
CreateNetwork.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include <doctest/doctest.h>
8 
9 #include "google/protobuf/stubs/logging.h"
10 
11 TEST_SUITE("OnnxParser_CreateNetwork")
12 {
13 TEST_CASE("CreateNetworkFromString")
14 {
15  std::string TestModel = R"(
16  ir_version: 3
17  producer_name: "CNTK "
18  producer_version: "2.5.1 "
19  domain: "ai.cntk "
20  model_version: 1
21  graph {
22  name: "CNTKGraph "
23  output {
24  name: "Output"
25  type {
26  tensor_type {
27  elem_type: 1
28  shape {
29  dim {
30  dim_value: 1
31  }
32  dim {
33  dim_value: 10
34  }
35  }
36  }
37  }
38  }
39  }
40  opset_import {
41  version: 7
42  })";
43 
45 
46  armnn::INetworkPtr network = parser->CreateNetworkFromString(TestModel.c_str());
47  CHECK(network.get());
48 }
49 
50 TEST_CASE("CreateNetworkFromStringWithNullptr")
51 {
53  CHECK_THROWS_AS(parser->CreateNetworkFromString(""), armnn::InvalidArgumentException );
54 }
55 
56 TEST_CASE("CreateNetworkWithInvalidString")
57 {
58  auto silencer = google::protobuf::LogSilencer(); //get rid of errors from protobuf
60  CHECK_THROWS_AS(parser->CreateNetworkFromString( "I'm not a model so I should raise an error" ),
62 }
63 
64 }
TEST_SUITE("OnnxParser_CreateNetwork")
static IOnnxParserPtr Create()
Definition: OnnxParser.cpp:38
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:241
std::unique_ptr< IOnnxParser, void(*)(IOnnxParser *parser)> IOnnxParserPtr
Definition: IOnnxParser.hpp:21