blob: 8777757a961450801429b1edeb6b405877a77b3a [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa01c577f2c2018-08-31 09:22:23 +01004//
5
6#include <boost/test/unit_test.hpp>
7#include "armnnOnnxParser/IOnnxParser.hpp"
8#include "ParserPrototxtFixture.hpp"
9
10BOOST_AUTO_TEST_SUITE(OnnxParser)
11
12struct ConstMainFixture : public armnnUtils::ParserPrototxtFixture<armnnOnnxParser::IOnnxParser>
13{
14 ConstMainFixture(const std::string& dataType)
15 {
16 m_Prototext = R"(
17 ir_version: 3
18 producer_name: "CNTK "
19 producer_version: "2.5.1 "
20 domain: "ai.cntk "
21 model_version: 1
22 graph {
23 name: "CNTKGraph "
24 node {
25 output: "Output"
26 attribute {
27 name: "value"
28 t {
29 dims: 7
30 data_type: )" + dataType + R"(
31 float_data: 0.0
32 float_data: 1.0
33 float_data: 2.0
34 float_data: 3.0
35 float_data: 4.0
36 float_data: 5.0
37 float_data: 6.0
38
39 }
Matteo Martincigh44a71672018-12-11 13:46:52 +000040 type: 1
telsoa01c577f2c2018-08-31 09:22:23 +010041 }
42 name: "constantNode"
43 op_type: "Constant"
44 }
45 output {
46 name: "Output"
47 type {
48 tensor_type {
Matteo Martincigh44a71672018-12-11 13:46:52 +000049 elem_type: 1
telsoa01c577f2c2018-08-31 09:22:23 +010050 shape {
51 dim {
52 dim_value: 7
53 }
54 }
55 }
56 }
57 }
58 }
59 opset_import {
60 version: 7
61 })";
62 }
63};
64
65struct ConstValidFixture : ConstMainFixture
66{
Matteo Martincigh44a71672018-12-11 13:46:52 +000067 ConstValidFixture() : ConstMainFixture("1") {
telsoa01c577f2c2018-08-31 09:22:23 +010068 Setup();
69 }
70};
71
72struct ConstInvalidFixture : ConstMainFixture
73{
Matteo Martincigh44a71672018-12-11 13:46:52 +000074 ConstInvalidFixture() : ConstMainFixture("10") { }
telsoa01c577f2c2018-08-31 09:22:23 +010075};
76
77BOOST_FIXTURE_TEST_CASE(ValidConstTest, ConstValidFixture)
78{
79 RunTest<1>({ }, {{ "Output" , {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0}}});
80}
81
82BOOST_FIXTURE_TEST_CASE(IncorrectDataTypeConst, ConstInvalidFixture)
83{
84 BOOST_CHECK_THROW( Setup(), armnn::ParseException);
85}
86
87BOOST_AUTO_TEST_SUITE_END()