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