blob: d7c207f7834f7b5a21e1b4b959957348470dc610 [file] [log] [blame]
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -02001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -02006#include "ParserFlatbuffersFixture.hpp"
7#include "../TfLiteParser.hpp"
8
Sadik Armagan1625efc2021-06-10 18:24:34 +01009#include <doctest/doctest.h>
10
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -020011#include <string>
12#include <iostream>
13
Sadik Armagan1625efc2021-06-10 18:24:34 +010014TEST_SUITE("TensorflowLiteParser_Addition")
15{
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -020016struct AddFixture : public ParserFlatbuffersFixture
17{
18 explicit AddFixture(const std::string & inputShape1,
19 const std::string & inputShape2,
20 const std::string & outputShape,
21 const std::string & activation="NONE")
22 {
23 m_JsonString = R"(
24 {
25 "version": 3,
26 "operator_codes": [ { "builtin_code": "ADD" } ],
27 "subgraphs": [ {
28 "tensors": [
29 {
30 "shape": )" + inputShape1 + R"(,
31 "type": "UINT8",
32 "buffer": 0,
33 "name": "inputTensor1",
34 "quantization": {
35 "min": [ 0.0 ],
36 "max": [ 255.0 ],
37 "scale": [ 1.0 ],
38 "zero_point": [ 0 ],
39 }
40 },
41 {
42 "shape": )" + inputShape2 + R"(,
43 "type": "UINT8",
44 "buffer": 1,
45 "name": "inputTensor2",
46 "quantization": {
47 "min": [ 0.0 ],
48 "max": [ 255.0 ],
49 "scale": [ 1.0 ],
50 "zero_point": [ 0 ],
51 }
52 },
53 {
54 "shape": )" + outputShape + R"( ,
55 "type": "UINT8",
56 "buffer": 2,
57 "name": "outputTensor",
58 "quantization": {
59 "min": [ 0.0 ],
60 "max": [ 255.0 ],
61 "scale": [ 1.0 ],
62 "zero_point": [ 0 ],
63 }
64 }
65 ],
66 "inputs": [ 0, 1 ],
67 "outputs": [ 2 ],
68 "operators": [
69 {
70 "opcode_index": 0,
71 "inputs": [ 0, 1 ],
72 "outputs": [ 2 ],
73 "builtin_options_type": "AddOptions",
74 "builtin_options": {
75 "fused_activation_function": )" + activation + R"(
76 },
77 "custom_options_format": "FLEXBUFFERS"
78 }
79 ],
80 } ],
81 "buffers" : [
82 { },
83 { }
84 ]
85 }
86 )";
87 Setup();
88 }
89};
90
91
92struct SimpleAddFixture : AddFixture
93{
94 SimpleAddFixture() : AddFixture("[ 2, 2 ]",
95 "[ 2, 2 ]",
96 "[ 2, 2 ]") {}
97};
98
Sadik Armagan1625efc2021-06-10 18:24:34 +010099TEST_CASE_FIXTURE(SimpleAddFixture, "SimpleAdd")
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -0200100{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000101 RunTest<2, armnn::DataType::QAsymmU8>(
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +0000102 0,
103 {{"inputTensor1", { 0, 1, 2, 3 }},
104 {"inputTensor2", { 4, 5, 6, 7 }}},
105 {{"outputTensor", { 4, 6, 8, 10 }}});
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -0200106}
107
Sadik Armagan1625efc2021-06-10 18:24:34 +0100108}