blob: d11f7603b2f4c08f25677ad49f8ba73d3b539790 [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// See LICENSE file in the project root for full license information.
4//
5
6#include <boost/test/unit_test.hpp>
7#include "armnnOnnxParser/IOnnxParser.hpp"
8#include "google/protobuf/stubs/logging.h"
9
10BOOST_AUTO_TEST_SUITE(OnnxParser)
11
12BOOST_AUTO_TEST_CASE(CreateNetworkFromString)
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: FLOAT
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
43 armnnOnnxParser::IOnnxParserPtr parser(armnnOnnxParser::IOnnxParser::Create());
44
45 armnn::INetworkPtr network = parser->CreateNetworkFromString(TestModel.c_str());
46 BOOST_TEST(network.get());
47}
48
49BOOST_AUTO_TEST_CASE(CreateNetworkFromStringWithNullptr)
50{
51 armnnOnnxParser::IOnnxParserPtr parser(armnnOnnxParser::IOnnxParser::Create());
52 BOOST_CHECK_THROW(parser->CreateNetworkFromString(""), armnn::InvalidArgumentException );
53}
54
55BOOST_AUTO_TEST_CASE(CreateNetworkWithInvalidString)
56{
57 auto silencer = google::protobuf::LogSilencer(); //get rid of errors from protobuf
58 armnnOnnxParser::IOnnxParserPtr parser(armnnOnnxParser::IOnnxParser::Create());
59 BOOST_CHECK_THROW(parser->CreateNetworkFromString( "I'm not a model so I should raise an error" ),
60 armnn::ParseException );
61}
62
63BOOST_AUTO_TEST_SUITE_END()