1 // 2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #include "ParserFlatbuffersFixture.hpp" 7 8 9 TEST_SUITE("TensorflowLiteParser_ResizeNearestNeighbor") 10 { 11 struct ResizeNearestNeighborFixture : public ParserFlatbuffersFixture 12 { ResizeNearestNeighborFixtureResizeNearestNeighborFixture13 explicit ResizeNearestNeighborFixture(const std::string & inputShape, 14 const std::string & outputShape, 15 const std::string & sizeShape, 16 const std::string & sizeData) 17 { 18 m_JsonString = R"( 19 { 20 "version": 3, 21 "operator_codes": [ { "builtin_code": "RESIZE_NEAREST_NEIGHBOR" } ], 22 "subgraphs": [ { 23 "tensors": [ 24 { 25 "shape": )" + sizeShape + R"( , 26 "type": "INT32", 27 "buffer": 0, 28 "name": "sizeTensor", 29 "quantization": { 30 "min": [ 0.0 ], 31 "max": [ 255.0 ], 32 "scale": [ 1.0 ], 33 "zero_point": [ 0 ], 34 } 35 }, 36 { 37 "shape": )" + inputShape + R"(, 38 "type": "FLOAT32", 39 "buffer": 1, 40 "name": "InputTensor", 41 "quantization": { 42 "min": [ 0.0 ], 43 "max": [ 255.0 ], 44 "scale": [ 1.0 ], 45 "zero_point": [ 0 ], 46 } 47 }, 48 { 49 "shape": )" + outputShape + R"( , 50 "type": "FLOAT32", 51 "buffer": 2, 52 "name": "OutputTensor", 53 "quantization": { 54 "min": [ 0.0 ], 55 "max": [ 255.0 ], 56 "scale": [ 1.0 ], 57 "zero_point": [ 0 ], 58 } 59 } 60 ], 61 "inputs": [ 1 ], 62 "outputs": [ 2 ], 63 "operators": [ 64 { 65 "opcode_index": 0, 66 "inputs": [ 1, 0 ], 67 "outputs": [ 2 ], 68 "builtin_options_type": "ResizeNearestNeighborOptions", 69 "builtin_options": { 70 }, 71 "custom_options_format": "FLEXBUFFERS" 72 } 73 ], 74 } ], 75 "buffers" : [ 76 { "data": )" + sizeData + R"(, }, 77 { }, 78 { }, 79 ] 80 } 81 )"; 82 Setup(); 83 } 84 }; 85 86 87 struct SimpleResizeNearestNeighborFixture : ResizeNearestNeighborFixture 88 { SimpleResizeNearestNeighborFixtureSimpleResizeNearestNeighborFixture89 SimpleResizeNearestNeighborFixture() 90 : ResizeNearestNeighborFixture("[ 1, 2, 2, 1 ]", // inputShape 91 "[ 1, 1, 1, 1 ]", // outputShape 92 "[ 2 ]", // sizeShape 93 "[ 1,0,0,0, 1,0,0,0 ]") // sizeData 94 {} 95 }; 96 97 TEST_CASE_FIXTURE(SimpleResizeNearestNeighborFixture, "ParseResizeNearestNeighbor") 98 { 99 RunTest<4, armnn::DataType::Float32>( 100 0, 101 {{"InputTensor", { 1.0f, 2.0f, 3.0f, 4.0f }}}, 102 {{"OutputTensor", { 1.0f }}}); 103 } 104 105 } 106