2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include <boost/test/unit_test.hpp>
7 #include "ParserFlatbuffersFixture.hpp"
8 #include "../TfLiteParser.hpp"
13 BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
15 struct FullyConnectedFixture : public ParserFlatbuffersFixture
17 explicit FullyConnectedFixture(const std::string& inputShape,
18 const std::string& outputShape,
19 const std::string& filterShape,
20 const std::string& filterData,
21 const std::string biasShape = "",
22 const std::string biasData = "")
24 std::string inputTensors = "[ 0, 2 ]";
25 std::string biasTensor = "";
26 std::string biasBuffer = "";
27 if (biasShape.size() > 0 && biasData.size() > 0)
29 inputTensors = "[ 0, 2, 3 ]";
32 "shape": )" + biasShape + R"( ,
44 { "data": )" + biasData + R"(, }, )";
49 "operator_codes": [ { "builtin_code": "FULLY_CONNECTED" } ],
53 "shape": )" + inputShape + R"(,
56 "name": "inputTensor",
65 "shape": )" + outputShape + R"(,
68 "name": "outputTensor",
77 "shape": )" + filterShape + R"(,
80 "name": "filterTensor",
87 }, )" + biasTensor + R"(
94 "inputs": )" + inputTensors + R"(,
96 "builtin_options_type": "FullyConnectedOptions",
98 "fused_activation_function": "NONE"
100 "custom_options_format": "FLEXBUFFERS"
107 { "data": )" + filterData + R"(, }, )"
112 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
116 struct FullyConnectedWithNoBiasFixture : FullyConnectedFixture
118 FullyConnectedWithNoBiasFixture()
119 : FullyConnectedFixture("[ 1, 4, 1, 1 ]", // inputShape
120 "[ 1, 1 ]", // outputShape
121 "[ 1, 4 ]", // filterShape
122 "[ 2, 3, 4, 5 ]") // filterData
126 BOOST_FIXTURE_TEST_CASE(FullyConnectedWithNoBias, FullyConnectedWithNoBiasFixture)
128 RunTest<2, armnn::DataType::QuantisedAsymm8>(
134 struct FullyConnectedWithBiasFixture : FullyConnectedFixture
136 FullyConnectedWithBiasFixture()
137 : FullyConnectedFixture("[ 1, 4, 1, 1 ]", // inputShape
138 "[ 1, 1 ]", // outputShape
139 "[ 1, 4 ]", // filterShape
140 "[ 2, 3, 4, 5 ]", // filterData
141 "[ 1 ]", // biasShape
142 "[ 10, 0, 0, 0 ]" ) // biasData
146 BOOST_FIXTURE_TEST_CASE(ParseFullyConnectedWithBias, FullyConnectedWithBiasFixture)
148 RunTest<2, armnn::DataType::QuantisedAsymm8>(
154 BOOST_AUTO_TEST_SUITE_END()