blob: 15879c2bed9c4ba3761f29b1883e7d68bd049024 [file] [log] [blame]
surmeh01bceff2f2018-03-29 16:29:27 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
surmeh01bceff2f2018-03-29 16:29:27 +01004//
5
6#include <boost/test/unit_test.hpp>
7#include "armnnTfParser/ITfParser.hpp"
8#include "ParserPrototxtFixture.hpp"
9
10BOOST_AUTO_TEST_SUITE(TensorflowParser)
11
telsoa01c577f2c2018-08-31 09:22:23 +010012struct MultiOutMatchFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
surmeh01bceff2f2018-03-29 16:29:27 +010013{
14 MultiOutMatchFixture()
15 {
16 m_Prototext = R"(
17node {
18 name: "input"
19 op: "Placeholder"
20 attr {
21 key: "dtype"
22 value {
23 type: DT_FLOAT
24 }
25 }
26 attr {
27 key: "shape"
28 value {
29 shape {
30 }
31 }
32 }
33}
34node {
35 name: "softmax1"
36 op: "Softmax"
37 input: "input:0"
38 attr {
39 key: "T"
40 value {
41 type: DT_FLOAT
42 }
43 }
44}
45 )";
46 SetupSingleInputSingleOutput({ 1, 7 }, "input", "softmax1");
47 }
48};
49
50BOOST_FIXTURE_TEST_CASE(MultiOutMatch, MultiOutMatchFixture)
51{
52 // Note that the point of this test is to verify the parsing went well.
53 // Here we make sure the softmax has really connected to the input layer.
54 RunTest<2>({ 0, 0, 10000, 0, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0 });
55}
56
telsoa01c577f2c2018-08-31 09:22:23 +010057struct MultiOutFailFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
surmeh01bceff2f2018-03-29 16:29:27 +010058{
59 MultiOutFailFixture()
60 {
61 m_Prototext = R"(
62node {
63 name: "input"
64 op: "Placeholder"
65 attr {
66 key: "dtype"
67 value {
68 type: DT_FLOAT
69 }
70 }
71 attr {
72 key: "shape"
73 value {
74 shape {
75 }
76 }
77 }
78}
79node {
80 name: "softmax1"
81 op: "Softmax"
82 input: "input:1"
83 attr {
84 key: "T"
85 value {
86 type: DT_FLOAT
87 }
88 }
89}
90 )";
91 BOOST_CHECK_THROW(SetupSingleInputSingleOutput({ 1, 7 }, "input", "softmax1"), armnn::ParseException);
92 }
93};
94
95BOOST_FIXTURE_TEST_CASE(MultiOutFail, MultiOutFailFixture)
96{
97 // Not running the graph because this is expected to throw an exception during parsing.
98}
99
telsoa01c577f2c2018-08-31 09:22:23 +0100100struct MultiOutInvalidFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
surmeh01bceff2f2018-03-29 16:29:27 +0100101{
102 MultiOutInvalidFixture()
103 {
104 m_Prototext = R"(
105node {
106 name: "input"
107 op: "Placeholder"
108 attr {
109 key: "dtype"
110 value {
111 type: DT_FLOAT
112 }
113 }
114 attr {
115 key: "shape"
116 value {
117 shape {
118 }
119 }
120 }
121}
122node {
123 name: "softmax1"
124 op: "Softmax"
125 input: "input:-1"
126 attr {
127 key: "T"
128 value {
129 type: DT_FLOAT
130 }
131 }
132}
133 )";
134 BOOST_CHECK_THROW(SetupSingleInputSingleOutput({ 1, 7 }, "input", "softmax1"), armnn::ParseException);
135 }
136};
137
138BOOST_FIXTURE_TEST_CASE(MultiOutInvalid, MultiOutInvalidFixture)
139{
140 // Not running the graph because this is expected to throw an exception during parsing.
141}
142
143
144BOOST_AUTO_TEST_SUITE_END()