blob: 3f0fdf14d0d695d8ff9bff1af00d2172739eaf9a [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
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 MeanNoReduceFixture : public ParserFlatbuffersFixture
16{
17 explicit MeanNoReduceFixture(const std::string & inputShape,
18 const std::string & outputShape,
19 const std::string & dimShape,
20 const std::string & dimData)
21 {
22 m_JsonString = R"(
23 {
24 "version": 3,
25 "operator_codes": [ { "builtin_code": "MEAN" } ],
26 "subgraphs": [ {
27 "tensors": [
28 {
29 "shape": )" + inputShape + R"(,
30 "type": "FLOAT32",
31 "buffer": 0,
32 "name": "inputTensor",
33 "quantization": {
34 "min": [ 0.0 ],
35 "max": [ 255.0 ],
36 "scale": [ 1.0 ],
37 "zero_point": [ 0 ],
38 }
39 },
40 {
41 "shape": )" + outputShape + R"( ,
42 "type": "FLOAT32",
43 "buffer": 1,
44 "name": "outputTensor",
45 "quantization": {
46 "min": [ 0.0 ],
47 "max": [ 255.0 ],
48 "scale": [ 1.0 ],
49 "zero_point": [ 0 ],
50 }
51 },
52 {
53 "shape": )" + dimShape + R"( ,
54 "type": "INT32",
55 "buffer": 2,
56 "name": "dimShape",
57 "quantization": {
58 "min": [ 0.0 ],
59 "max": [ 255.0 ],
60 "scale": [ 1.0 ],
61 "zero_point": [ 0 ],
62 }
63 }
64 ],
65 "inputs": [ 0 ],
66 "outputs": [ 1 ],
67 "operators": [
68 {
69 "opcode_index": 0,
70 "inputs": [ 0 , 2 ],
71 "outputs": [ 1 ],
72 "custom_options_format": "FLEXBUFFERS"
73 }
74 ],
75 } ],
76 "buffers" : [
77 { },
78 { },
79 { "data": )" + dimData + R"(, },
80 ]
81 }
82 )";
83 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
84 }
85};
86
87struct SimpleMeanNoReduceFixture : public MeanNoReduceFixture
88{
89 SimpleMeanNoReduceFixture() : MeanNoReduceFixture("[ 2, 2 ]", "[ 1, 1 ]", "[ 0 ]", "[ ]") {}
90};
91
92BOOST_FIXTURE_TEST_CASE(ParseMeanNoReduce, SimpleMeanNoReduceFixture)
93{
Nattapat Chaimanowong649dd952019-01-22 16:10:44 +000094 RunTest<2, armnn::DataType::Float32>(0, {{ "inputTensor", { 1.0f, 1.0f, 2.0f, 2.0f } } },
95 {{ "outputTensor", { 1.5f } } });
Bruno Goncalves2235cee2018-12-19 12:51:45 -020096}
97
98BOOST_AUTO_TEST_SUITE_END()