Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 1 | // |
Finn Williams | b49ed18 | 2021-06-29 15:50:08 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 6 | #include "ParserFlatbuffersFixture.hpp" |
Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 7 | |
Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 8 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 9 | TEST_SUITE("TensorflowLiteParser_Mean") |
| 10 | { |
Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 11 | struct 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 | |
| 83 | struct SimpleMeanNoReduceFixture : public MeanNoReduceFixture |
| 84 | { |
| 85 | SimpleMeanNoReduceFixture() : MeanNoReduceFixture("[ 2, 2 ]", "[ 1, 1 ]", "[ 0 ]", "[ ]") {} |
| 86 | }; |
| 87 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 88 | TEST_CASE_FIXTURE(SimpleMeanNoReduceFixture, "ParseMeanNoReduce") |
Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 89 | { |
Nattapat Chaimanowong | 649dd95 | 2019-01-22 16:10:44 +0000 | [diff] [blame] | 90 | RunTest<2, armnn::DataType::Float32>(0, {{ "inputTensor", { 1.0f, 1.0f, 2.0f, 2.0f } } }, |
| 91 | {{ "outputTensor", { 1.5f } } }); |
Bruno Goncalves | 2235cee | 2018-12-19 12:51:45 -0200 | [diff] [blame] | 92 | } |
| 93 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 94 | } |