1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// See LICENSE file in the project root for full license information.
//
#include <boost/test/unit_test.hpp>
#include "armnnTfParser/ITfParser.hpp"
#include "ParserPrototxtFixture.hpp"
BOOST_AUTO_TEST_SUITE(TensorflowParser)
struct BiasAddFixture : public ParserPrototxtFixture<armnnTfParser::ITfParser>
{
explicit BiasAddFixture(const std::string& dataFormat)
{
m_Prototext = R"(
node {
name: "graphInput"
op: "Placeholder"
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
attr {
key: "shape"
value {
shape {
}
}
}
}
node {
name: "bias"
op: "Const"
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_FLOAT
tensor_shape {
dim {
size: 3
}
}
float_val: 1
float_val: 2
float_val: 3
}
}
}
}
node {
name: "biasAdd"
op : "BiasAdd"
input: "graphInput"
input: "bias"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "data_format"
value {
s: ")" + dataFormat + R"("
}
}
}
)";
SetupSingleInputSingleOutput({ 1, 3, 1, 3 }, "graphInput", "biasAdd");
}
};
struct BiasAddFixtureNCHW : BiasAddFixture
{
BiasAddFixtureNCHW() : BiasAddFixture("NCHW") {}
};
struct BiasAddFixtureNHWC : BiasAddFixture
{
BiasAddFixtureNHWC() : BiasAddFixture("NHWC") {}
};
BOOST_FIXTURE_TEST_CASE(ParseBiasAddNCHW, BiasAddFixtureNCHW)
{
RunTest<4>(std::vector<float>(9), { 1, 1, 1, 2, 2, 2, 3, 3, 3 });
}
BOOST_FIXTURE_TEST_CASE(ParseBiasAddNHWC, BiasAddFixtureNHWC)
{
RunTest<4>(std::vector<float>(9), { 1, 2, 3, 1, 2, 3, 1, 2, 3 });
}
BOOST_AUTO_TEST_SUITE_END()
|