blob: 2da89e93e0919224da21a98e59c2123aafafd60f [file] [log] [blame]
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -02001//
Finn Williamsb49ed182021-06-29 15:50:08 +01002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -02003// SPDX-License-Identifier: MIT
4//
5
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -02006#include "ParserFlatbuffersFixture.hpp"
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -02007
Sadik Armagan1625efc2021-06-10 18:24:34 +01008#include <doctest/doctest.h>
9
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -020010
Sadik Armagan1625efc2021-06-10 18:24:34 +010011TEST_SUITE("TensorflowLiteParser_Addition")
12{
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -020013struct AddFixture : public ParserFlatbuffersFixture
14{
15 explicit AddFixture(const std::string & inputShape1,
16 const std::string & inputShape2,
17 const std::string & outputShape,
18 const std::string & activation="NONE")
19 {
20 m_JsonString = R"(
21 {
22 "version": 3,
23 "operator_codes": [ { "builtin_code": "ADD" } ],
24 "subgraphs": [ {
25 "tensors": [
26 {
27 "shape": )" + inputShape1 + R"(,
28 "type": "UINT8",
29 "buffer": 0,
30 "name": "inputTensor1",
31 "quantization": {
32 "min": [ 0.0 ],
33 "max": [ 255.0 ],
34 "scale": [ 1.0 ],
35 "zero_point": [ 0 ],
36 }
37 },
38 {
39 "shape": )" + inputShape2 + R"(,
40 "type": "UINT8",
41 "buffer": 1,
42 "name": "inputTensor2",
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": [ 0, 1 ],
64 "outputs": [ 2 ],
65 "operators": [
66 {
67 "opcode_index": 0,
68 "inputs": [ 0, 1 ],
69 "outputs": [ 2 ],
70 "builtin_options_type": "AddOptions",
71 "builtin_options": {
72 "fused_activation_function": )" + activation + R"(
73 },
74 "custom_options_format": "FLEXBUFFERS"
75 }
76 ],
77 } ],
78 "buffers" : [
79 { },
80 { }
81 ]
82 }
83 )";
84 Setup();
85 }
86};
87
88
89struct SimpleAddFixture : AddFixture
90{
91 SimpleAddFixture() : AddFixture("[ 2, 2 ]",
92 "[ 2, 2 ]",
93 "[ 2, 2 ]") {}
94};
95
Sadik Armagan1625efc2021-06-10 18:24:34 +010096TEST_CASE_FIXTURE(SimpleAddFixture, "SimpleAdd")
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -020097{
Derek Lambertif90c56d2020-01-10 17:14:08 +000098 RunTest<2, armnn::DataType::QAsymmU8>(
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +000099 0,
100 {{"inputTensor1", { 0, 1, 2, 3 }},
101 {"inputTensor2", { 4, 5, 6, 7 }}},
102 {{"outputTensor", { 4, 6, 8, 10 }}});
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -0200103}
104
Sadik Armagan1625efc2021-06-10 18:24:34 +0100105}