Bruno Goncalves | 3d7efe9 | 2018-12-27 14:21:43 -0200 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include <boost/test/unit_test.hpp> |
| 7 | #include "ParserFlatbuffersFixture.hpp" |
| 8 | #include "../TfLiteParser.hpp" |
| 9 | |
| 10 | #include <string> |
| 11 | #include <iostream> |
| 12 | |
Kevin May | 7d96b16 | 2021-02-03 17:38:41 +0000 | [diff] [blame] | 13 | using armnnTfLiteParser::TfLiteParserImpl; |
Bruno Goncalves | 3d7efe9 | 2018-12-27 14:21:43 -0200 | [diff] [blame] | 14 | |
| 15 | BOOST_AUTO_TEST_SUITE(TensorflowLiteParser) |
| 16 | |
| 17 | struct ConstantAddFixture : public ParserFlatbuffersFixture |
| 18 | { |
| 19 | explicit ConstantAddFixture(const std::string & inputShape, |
| 20 | const std::string & outputShape, |
| 21 | const std::string & constShape, |
| 22 | const std::string & constData) |
| 23 | { |
| 24 | m_JsonString = R"( |
| 25 | { |
| 26 | "version": 3, |
| 27 | "operator_codes": [ { "builtin_code": "ADD" } ], |
| 28 | "subgraphs": [ { |
| 29 | "tensors": [ |
| 30 | { |
| 31 | "shape": )" + constShape + R"( , |
| 32 | "type": "UINT8", |
| 33 | "buffer": 3, |
| 34 | "name": "ConstTensor", |
| 35 | "quantization": { |
| 36 | "min": [ 0.0 ], |
| 37 | "max": [ 255.0 ], |
| 38 | "scale": [ 1.0 ], |
| 39 | "zero_point": [ 0 ], |
| 40 | } |
| 41 | }, |
| 42 | { |
| 43 | "shape": )" + inputShape + R"(, |
| 44 | "type": "UINT8", |
| 45 | "buffer": 1, |
| 46 | "name": "InputTensor", |
| 47 | "quantization": { |
| 48 | "min": [ 0.0 ], |
| 49 | "max": [ 255.0 ], |
| 50 | "scale": [ 1.0 ], |
| 51 | "zero_point": [ 0 ], |
| 52 | } |
| 53 | }, |
| 54 | { |
| 55 | "shape": )" + outputShape + R"( , |
| 56 | "type": "UINT8", |
| 57 | "buffer": 2, |
| 58 | "name": "OutputTensor", |
| 59 | "quantization": { |
| 60 | "min": [ 0.0 ], |
| 61 | "max": [ 255.0 ], |
| 62 | "scale": [ 1.0 ], |
| 63 | "zero_point": [ 0 ], |
| 64 | } |
| 65 | } |
| 66 | ], |
| 67 | "inputs": [ 1 ], |
| 68 | "outputs": [ 2 ], |
| 69 | "operators": [ |
| 70 | { |
| 71 | "opcode_index": 0, |
| 72 | "inputs": [ 1, 0 ], |
| 73 | "outputs": [ 2 ], |
| 74 | "builtin_options_type": "AddOptions", |
| 75 | "builtin_options": { |
| 76 | }, |
| 77 | "custom_options_format": "FLEXBUFFERS" |
| 78 | } |
| 79 | ], |
| 80 | } ], |
| 81 | "buffers" : [ |
| 82 | { }, |
| 83 | { }, |
| 84 | { }, |
| 85 | { "data": )" + constData + R"(, }, |
| 86 | ] |
| 87 | } |
| 88 | )"; |
| 89 | Setup(); |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | |
| 94 | struct SimpleConstantAddFixture : ConstantAddFixture |
| 95 | { |
| 96 | SimpleConstantAddFixture() |
| 97 | : ConstantAddFixture("[ 2, 2 ]", // inputShape |
| 98 | "[ 2, 2 ]", // outputShape |
| 99 | "[ 2, 2 ]", // constShape |
| 100 | "[ 4,5, 6,7 ]") // constData |
| 101 | {} |
| 102 | }; |
| 103 | |
| 104 | BOOST_FIXTURE_TEST_CASE(SimpleConstantAdd, SimpleConstantAddFixture) |
| 105 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 106 | RunTest<2, armnn::DataType::QAsymmU8>( |
Bruno Goncalves | 3d7efe9 | 2018-12-27 14:21:43 -0200 | [diff] [blame] | 107 | 0, |
| 108 | {{"InputTensor", { 0, 1, 2, 3 }}}, |
| 109 | {{"OutputTensor", { 4, 6, 8, 10 }}} |
| 110 | ); |
| 111 | } |
| 112 | |
| 113 | BOOST_AUTO_TEST_SUITE_END() |