// // Copyright © 2021, 2023-2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #include "PackTestHelper.hpp" #include namespace armnnDelegate { template void PackFp32Axis0Test(tflite::TensorType tensorType) { std::vector inputShape { 3, 2, 3 }; std::vector expectedOutputShape { 2, 3, 2, 3 }; std::vector> inputValues; inputValues.push_back( { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); inputValues.push_back( { 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }); std::vector expectedOutputValues = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }; PackTest(tflite::BuiltinOperator_PACK, tensorType, inputShape, expectedOutputShape, inputValues, expectedOutputValues, {}, 0); } template void PackFp32Axis1Test(tflite::TensorType tensorType) { std::vector inputShape { 3, 2, 3 }; std::vector expectedOutputShape { 3, 2, 2, 3 }; std::vector> inputValues; inputValues.push_back( { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); inputValues.push_back( { 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }); std::vector expectedOutputValues = { 1, 2, 3, 4, 5, 6, 19, 20, 21, 22, 23, 24, 7, 8, 9, 10, 11, 12, 25, 26, 27, 28, 29, 30, 13, 14, 15, 16, 17, 18, 31, 32, 33, 34, 35, 36 }; PackTest(tflite::BuiltinOperator_PACK, tensorType, inputShape, expectedOutputShape, inputValues, expectedOutputValues, {}, 1); } template void PackFp32Axis2Test(tflite::TensorType tensorType) { std::vector inputShape { 3, 2, 3 }; std::vector expectedOutputShape { 3, 2, 2, 3 }; std::vector> inputValues; inputValues.push_back( { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); inputValues.push_back( { 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }); std::vector expectedOutputValues = { 1, 2, 3, 19, 20, 21, 4, 5, 6, 22, 23, 24, 7, 8, 9, 25, 26, 27, 10, 11, 12, 28, 29, 30, 13, 14, 15, 31, 32, 33, 16, 17, 18, 34, 35, 36 }; PackTest(tflite::BuiltinOperator_PACK, tensorType, inputShape, expectedOutputShape, inputValues, expectedOutputValues, {}, 2); } template void PackFp32Axis3Test(tflite::TensorType tensorType) { std::vector inputShape { 3, 2, 3 }; std::vector expectedOutputShape { 3, 2, 3, 2 }; std::vector> inputValues; inputValues.push_back( { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); inputValues.push_back( { 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }); std::vector expectedOutputValues = { 1, 19, 2, 20, 3, 21, 4, 22, 5, 23, 6, 24, 7, 25, 8, 26, 9, 27, 10, 28, 11, 29, 12, 30, 13, 31, 14, 32, 15, 33, 16, 34, 17, 35, 18, 36 }; PackTest(tflite::BuiltinOperator_PACK, tflite::TensorType_FLOAT32, inputShape, expectedOutputShape, inputValues, expectedOutputValues, {}, 3); } template void PackFp32Inputs3Test(tflite::TensorType tensorType) { std::vector inputShape { 3, 3 }; std::vector expectedOutputShape { 3, 3, 3 }; std::vector> inputValues; inputValues.push_back( { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); inputValues.push_back( { 10, 11, 12, 13, 14, 15, 16, 17, 18 }); inputValues.push_back( { 19, 20, 21, 22, 23, 24, 25, 26, 27 }); std::vector expectedOutputValues = { 1, 2, 3, 10, 11, 12, 19, 20, 21, 4, 5, 6, 13, 14, 15, 22, 23, 24, 7, 8, 9, 16, 17, 18, 25, 26, 27 }; PackTest(tflite::BuiltinOperator_PACK, tensorType, inputShape, expectedOutputShape, inputValues, expectedOutputValues, {}, 1); } TEST_SUITE("PackTests") { // Fp32 TEST_CASE ("Pack_Fp32_Axis0_Test") { PackFp32Axis0Test(tflite::TensorType_FLOAT32); } TEST_CASE ("Pack_Fp32_Axis1_Test") { PackFp32Axis1Test(tflite::TensorType_FLOAT32); } TEST_CASE ("Pack_Fp32_Axis2_Test") { PackFp32Axis2Test(tflite::TensorType_FLOAT32); } TEST_CASE ("Pack_Fp32_Axis3_Test") { PackFp32Axis3Test(tflite::TensorType_FLOAT32); } TEST_CASE ("Pack_Fp32_Inputs3_Test") { PackFp32Inputs3Test(tflite::TensorType_FLOAT32); } // Uint8 TEST_CASE ("Pack_Uint8_Axis0_Test") { PackFp32Axis0Test(tflite::TensorType_UINT8); } TEST_CASE ("Pack_Uint8_Inputs3_Test") { PackFp32Inputs3Test(tflite::TensorType_UINT8); } // Int8 TEST_CASE ("Pack_Int8_Axis0_Test") { PackFp32Axis0Test(tflite::TensorType_INT8); } TEST_CASE ("Pack_Int8_Inputs3_Test") { PackFp32Inputs3Test(tflite::TensorType_INT8); } } } // namespace armnnDelegate