blob: 77bdeb52f8ccdb6ebc9388f1a2addf912b3b0360 [file] [log] [blame]
Bruno Goncalves2235cee2018-12-19 12:51:45 -02001//
Finn Williamsb49ed182021-06-29 15:50:08 +01002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
Bruno Goncalves2235cee2018-12-19 12:51:45 -02003// SPDX-License-Identifier: MIT
4//
5
Bruno Goncalves2235cee2018-12-19 12:51:45 -02006#include "ParserFlatbuffersFixture.hpp"
Bruno Goncalves2235cee2018-12-19 12:51:45 -02007
Bruno Goncalves2235cee2018-12-19 12:51:45 -02008
Sadik Armagan1625efc2021-06-10 18:24:34 +01009TEST_SUITE("TensorflowLiteParser_Mean")
10{
Bruno Goncalves2235cee2018-12-19 12:51:45 -020011struct MeanNoReduceFixture : public ParserFlatbuffersFixture
12{
13 explicit MeanNoReduceFixture(const std::string & inputShape,
14 const std::string & outputShape,
15 const std::string & dimShape,
16 const std::string & dimData)
17 {
18 m_JsonString = R"(
19 {
20 "version": 3,
21 "operator_codes": [ { "builtin_code": "MEAN" } ],
22 "subgraphs": [ {
23 "tensors": [
24 {
25 "shape": )" + inputShape + R"(,
26 "type": "FLOAT32",
27 "buffer": 0,
28 "name": "inputTensor",
29 "quantization": {
30 "min": [ 0.0 ],
31 "max": [ 255.0 ],
32 "scale": [ 1.0 ],
33 "zero_point": [ 0 ],
34 }
35 },
36 {
37 "shape": )" + outputShape + R"( ,
38 "type": "FLOAT32",
39 "buffer": 1,
40 "name": "outputTensor",
41 "quantization": {
42 "min": [ 0.0 ],
43 "max": [ 255.0 ],
44 "scale": [ 1.0 ],
45 "zero_point": [ 0 ],
46 }
47 },
48 {
49 "shape": )" + dimShape + R"( ,
50 "type": "INT32",
51 "buffer": 2,
52 "name": "dimShape",
53 "quantization": {
54 "min": [ 0.0 ],
55 "max": [ 255.0 ],
56 "scale": [ 1.0 ],
57 "zero_point": [ 0 ],
58 }
59 }
60 ],
61 "inputs": [ 0 ],
62 "outputs": [ 1 ],
63 "operators": [
64 {
65 "opcode_index": 0,
66 "inputs": [ 0 , 2 ],
67 "outputs": [ 1 ],
68 "custom_options_format": "FLEXBUFFERS"
69 }
70 ],
71 } ],
72 "buffers" : [
73 { },
74 { },
75 { "data": )" + dimData + R"(, },
76 ]
77 }
78 )";
79 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
80 }
81};
82
83struct SimpleMeanNoReduceFixture : public MeanNoReduceFixture
84{
85 SimpleMeanNoReduceFixture() : MeanNoReduceFixture("[ 2, 2 ]", "[ 1, 1 ]", "[ 0 ]", "[ ]") {}
86};
87
Sadik Armagan1625efc2021-06-10 18:24:34 +010088TEST_CASE_FIXTURE(SimpleMeanNoReduceFixture, "ParseMeanNoReduce")
Bruno Goncalves2235cee2018-12-19 12:51:45 -020089{
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +000090 RunTest<2, armnn::DataType::Float32>(0, {{ "inputTensor", { 1.0f, 1.0f, 2.0f, 2.0f } } },
91 {{ "outputTensor", { 1.5f } } });
Bruno Goncalves2235cee2018-12-19 12:51:45 -020092}
93
Sadik Armagan1625efc2021-06-10 18:24:34 +010094}