1 // 2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #include "ParserFlatbuffersFixture.hpp" 7 8 9 TEST_SUITE("TensorflowLiteParser_Mean") 10 { 11 struct MeanNoReduceFixture : public ParserFlatbuffersFixture 12 { MeanNoReduceFixtureMeanNoReduceFixture13 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 { SimpleMeanNoReduceFixtureSimpleMeanNoReduceFixture85 SimpleMeanNoReduceFixture() : MeanNoReduceFixture("[ 2, 2 ]", "[ 1, 1 ]", "[ 0 ]", "[ ]") {} 86 }; 87 88 TEST_CASE_FIXTURE(SimpleMeanNoReduceFixture, "ParseMeanNoReduce") 89 { 90 RunTest<2, armnn::DataType::Float32>(0, {{ "inputTensor", { 1.0f, 1.0f, 2.0f, 2.0f } } }, 91 {{ "outputTensor", { 1.5f } } }); 92 } 93 94 } 95