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