ArmNN
 20.08
Const.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <boost/test/unit_test.hpp>
9 
10 BOOST_AUTO_TEST_SUITE(OnnxParser)
11 
12 struct 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  }
40  type: 1
41  }
42  name: "constantNode"
43  op_type: "Constant"
44  }
45  output {
46  name: "Output"
47  type {
48  tensor_type {
49  elem_type: 1
50  shape {
51  dim {
52  dim_value: 7
53  }
54  }
55  }
56  }
57  }
58  }
59  opset_import {
60  version: 7
61  })";
62  }
63 };
64 
65 struct ConstValidFixture : ConstMainFixture
66 {
67  ConstValidFixture() : ConstMainFixture("1") {
68  Setup();
69  }
70 };
71 
72 struct ConstInvalidFixture : ConstMainFixture
73 {
74  ConstInvalidFixture() : ConstMainFixture("10") { }
75 };
76 
77 BOOST_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 
82 BOOST_FIXTURE_TEST_CASE(IncorrectDataTypeConst, ConstInvalidFixture)
83 {
84  BOOST_CHECK_THROW( Setup(), armnn::ParseException);
85 }
86 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(ValidConstTest, ConstValidFixture)
Definition: Const.cpp:77
BOOST_AUTO_TEST_SUITE_END()