blob: deeb707a2f0331edb00a2543b0cd42a147c9e89c [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
6#include <boost/test/unit_test.hpp>
7#include "ParserFlatbuffersFixture.hpp"
8#include "../TfLiteParser.hpp"
9
10#include <string>
11#include <iostream>
12
13BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
14
15struct AddFixture : public ParserFlatbuffersFixture
16{
17 explicit AddFixture(const std::string & inputShape1,
18 const std::string & inputShape2,
19 const std::string & outputShape,
20 const std::string & activation="NONE")
21 {
22 m_JsonString = R"(
23 {
24 "version": 3,
25 "operator_codes": [ { "builtin_code": "ADD" } ],
26 "subgraphs": [ {
27 "tensors": [
28 {
29 "shape": )" + inputShape1 + R"(,
30 "type": "UINT8",
31 "buffer": 0,
32 "name": "inputTensor1",
33 "quantization": {
34 "min": [ 0.0 ],
35 "max": [ 255.0 ],
36 "scale": [ 1.0 ],
37 "zero_point": [ 0 ],
38 }
39 },
40 {
41 "shape": )" + inputShape2 + R"(,
42 "type": "UINT8",
43 "buffer": 1,
44 "name": "inputTensor2",
45 "quantization": {
46 "min": [ 0.0 ],
47 "max": [ 255.0 ],
48 "scale": [ 1.0 ],
49 "zero_point": [ 0 ],
50 }
51 },
52 {
53 "shape": )" + outputShape + R"( ,
54 "type": "UINT8",
55 "buffer": 2,
56 "name": "outputTensor",
57 "quantization": {
58 "min": [ 0.0 ],
59 "max": [ 255.0 ],
60 "scale": [ 1.0 ],
61 "zero_point": [ 0 ],
62 }
63 }
64 ],
65 "inputs": [ 0, 1 ],
66 "outputs": [ 2 ],
67 "operators": [
68 {
69 "opcode_index": 0,
70 "inputs": [ 0, 1 ],
71 "outputs": [ 2 ],
72 "builtin_options_type": "AddOptions",
73 "builtin_options": {
74 "fused_activation_function": )" + activation + R"(
75 },
76 "custom_options_format": "FLEXBUFFERS"
77 }
78 ],
79 } ],
80 "buffers" : [
81 { },
82 { }
83 ]
84 }
85 )";
86 Setup();
87 }
88};
89
90
91struct SimpleAddFixture : AddFixture
92{
93 SimpleAddFixture() : AddFixture("[ 2, 2 ]",
94 "[ 2, 2 ]",
95 "[ 2, 2 ]") {}
96};
97
98BOOST_FIXTURE_TEST_CASE(SimpleAdd, SimpleAddFixture)
99{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000100 RunTest<2, armnn::DataType::QAsymmU8>(
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +0000101 0,
102 {{"inputTensor1", { 0, 1, 2, 3 }},
103 {"inputTensor2", { 4, 5, 6, 7 }}},
104 {{"outputTensor", { 4, 6, 8, 10 }}});
Bruno Goncalvesd4ac6a42018-12-18 12:56:22 -0200105}
106
107BOOST_AUTO_TEST_SUITE_END()