Keith Davis | 0176fd8 | 2021-06-01 17:36:32 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2021 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ParserFlatbuffersFixture.hpp" |
| 7 | #include "../TfLiteParser.hpp" |
| 8 | |
| 9 | TEST_SUITE("TensorflowLiteParser_Shape") |
| 10 | { |
| 11 | struct ShapeFixture : public ParserFlatbuffersFixture |
| 12 | { |
| 13 | explicit ShapeFixture(const std::string& inputShape, |
| 14 | const std::string& outputShape, |
| 15 | const std::string& inputDataType, |
| 16 | const std::string& outputDataType) |
| 17 | { |
| 18 | m_JsonString = R"( |
| 19 | { |
| 20 | "version": 3, |
| 21 | "operator_codes": [ { "builtin_code": "SHAPE" } ], |
| 22 | "subgraphs": [ { |
| 23 | "tensors": [ |
| 24 | { |
| 25 | "shape": )" + inputShape + R"(, |
| 26 | "type": )" + inputDataType + R"(, |
| 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": )" + outputDataType + R"(, |
| 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 | "inputs": [ 0 ], |
| 50 | "outputs": [ 1 ], |
| 51 | "operators": [ |
| 52 | { |
| 53 | "opcode_index": 0, |
| 54 | "inputs": [ 0 ], |
| 55 | "outputs": [ 1 ], |
| 56 | "custom_options_format": "FLEXBUFFERS" |
| 57 | } |
| 58 | ], |
| 59 | } ], |
| 60 | "buffers" : [ {}, {} ] |
| 61 | } |
| 62 | )"; |
| 63 | SetupSingleInputSingleOutput("inputTensor", "outputTensor"); |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | struct SimpleShapeFixture : ShapeFixture |
| 69 | { |
| 70 | SimpleShapeFixture() : ShapeFixture("[ 1, 3, 3, 1 ]", |
| 71 | "[ 4 ]", |
| 72 | "INT32", |
| 73 | "INT32") {} |
| 74 | }; |
| 75 | |
| 76 | TEST_CASE_FIXTURE(SimpleShapeFixture, "SimpleShapeFixture") |
| 77 | { |
| 78 | RunTest<1, armnn::DataType::Signed32>( |
| 79 | 0, |
| 80 | {{"inputTensor", { 1, 1, 1, 1, 1, 1, 1, 1, 1 }}}, |
| 81 | {{"outputTensor",{ 1, 3, 3, 1 }}}); |
| 82 | } |
| 83 | |
| 84 | } |