blob: b6d0b58dbc69a1f39a108e584b19b30b3c8b83b8 [file] [log] [blame]
Bruno Goncalvesbbeae262019-02-07 18:37:39 -02001//
Finn Williamsb49ed182021-06-29 15:50:08 +01002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
Bruno Goncalvesbbeae262019-02-07 18:37:39 -02003// SPDX-License-Identifier: MIT
4//
5
Bruno Goncalvesbbeae262019-02-07 18:37:39 -02006#include "ParserFlatbuffersFixture.hpp"
Bruno Goncalvesbbeae262019-02-07 18:37:39 -02007
Bruno Goncalvesbbeae262019-02-07 18:37:39 -02008
Sadik Armagan1625efc2021-06-10 18:24:34 +01009TEST_SUITE("TensorflowLiteParser_Sub")
10{
Bruno Goncalvesbbeae262019-02-07 18:37:39 -020011struct SubFixture : public ParserFlatbuffersFixture
12{
13 explicit SubFixture(const std::string & inputShape1,
14 const std::string & inputShape2,
15 const std::string & outputShape,
16 const std::string & activation="NONE")
17 {
18 m_JsonString = R"(
19 {
20 "version": 3,
21 "operator_codes": [ { "builtin_code": "SUB" } ],
22 "subgraphs": [ {
23 "tensors": [
24 {
25 "shape": )" + inputShape1 + R"(,
26 "type": "UINT8",
27 "buffer": 0,
28 "name": "inputTensor1",
29 "quantization": {
30 "min": [ 0.0 ],
31 "max": [ 255.0 ],
32 "scale": [ 1.0 ],
33 "zero_point": [ 0 ],
34 }
35 },
36 {
37 "shape": )" + inputShape2 + R"(,
38 "type": "UINT8",
39 "buffer": 1,
40 "name": "inputTensor2",
41 "quantization": {
42 "min": [ 0.0 ],
43 "max": [ 255.0 ],
44 "scale": [ 1.0 ],
45 "zero_point": [ 0 ],
46 }
47 },
48 {
49 "shape": )" + outputShape + R"( ,
50 "type": "UINT8",
51 "buffer": 2,
52 "name": "outputTensor",
53 "quantization": {
54 "min": [ 0.0 ],
55 "max": [ 255.0 ],
56 "scale": [ 1.0 ],
57 "zero_point": [ 0 ],
58 }
59 }
60 ],
61 "inputs": [ 0, 1 ],
62 "outputs": [ 2 ],
63 "operators": [
64 {
65 "opcode_index": 0,
66 "inputs": [ 0, 1 ],
67 "outputs": [ 2 ],
68 "builtin_options_type": "SubOptions",
69 "builtin_options": {
70 "fused_activation_function": )" + activation + R"(
71 },
72 "custom_options_format": "FLEXBUFFERS"
73 }
74 ],
75 } ],
76 "buffers" : [
77 { },
78 { }
79 ]
80 }
81 )";
82 Setup();
83 }
84};
85
86
87struct SimpleSubFixture : SubFixture
88{
89 SimpleSubFixture() : SubFixture("[ 1, 4 ]",
90 "[ 1, 4 ]",
91 "[ 1, 4 ]") {}
92};
93
Sadik Armagan1625efc2021-06-10 18:24:34 +010094TEST_CASE_FIXTURE(SimpleSubFixture, "SimpleSub")
Bruno Goncalvesbbeae262019-02-07 18:37:39 -020095{
Derek Lambertif90c56d2020-01-10 17:14:08 +000096 RunTest<2, armnn::DataType::QAsymmU8>(
Bruno Goncalvesbbeae262019-02-07 18:37:39 -020097 0,
98 {{"inputTensor1", { 4, 5, 6, 7 }},
99 {"inputTensor2", { 3, 2, 1, 0 }}},
100 {{"outputTensor", { 1, 3, 5, 7 }}});
101}
102
Sadik Armagand109a4d2020-07-28 10:42:13 +0100103struct DynamicSubFixture : SubFixture
104{
105 DynamicSubFixture() : SubFixture("[ 1, 4 ]",
106 "[ 1, 4 ]",
107 "[ ]") {}
108};
109
Sadik Armagan1625efc2021-06-10 18:24:34 +0100110TEST_CASE_FIXTURE(DynamicSubFixture, "DynamicSub")
Sadik Armagand109a4d2020-07-28 10:42:13 +0100111{
112 RunTest<2, armnn::DataType::QAsymmU8, armnn::DataType::QAsymmU8>(
113 0,
114 {{"inputTensor1", { 4, 5, 6, 7 }},
115 {"inputTensor2", { 3, 2, 1, 0 }}},
116 {{"outputTensor", { 1, 3, 5, 7 }}},
117 true);
118}
119
Sadik Armagan1625efc2021-06-10 18:24:34 +0100120}