From 6bee1ab9fb9e9f4b7d36f3a7f7b971fe917e627e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=B5=9C=EC=84=B1=EC=A7=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 12 Apr 2018 21:56:21 +0900 Subject: [PATCH] add other test cases in pooling (#631) --- src/kernel/acl/src/cl/Pooling.test.cpp | 78 ++++++++++++++++++++++++++++++++ src/kernel/acl/src/neon/Pooling.test.cpp | 78 ++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/src/kernel/acl/src/cl/Pooling.test.cpp b/src/kernel/acl/src/cl/Pooling.test.cpp index 772e327..0e466b8 100644 --- a/src/kernel/acl/src/cl/Pooling.test.cpp +++ b/src/kernel/acl/src/cl/Pooling.test.cpp @@ -44,6 +44,45 @@ TEST(KernelACL_TC, maxPoolFloat32_3x3to1x1) EXPECT_EQ(bret, true); } +TEST(KernelACL_TC, maxPoolFloat32_3x3to2x2) +{ + float inputData[9]; + const android::nn::Shape inputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 }; + int32_t padding_left = 0; + int32_t padding_right = 0; + int32_t padding_top = 0; + int32_t padding_bottom = 0; + int32_t stride_width = 1; + int32_t stride_height = 1; + int32_t filter_width = 2; + int32_t filter_height = 2; + + float outputData[4]; + const android::nn::Shape outputShape = { OperandType::FLOAT32, {1,2,2,1}, 1.0, 0 }; + bool bret; + + util::initData_Increasing(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0); + util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0); + + int32_t activation = ANEURALNETWORKS_FUSED_NONE; + + bret = maxPoolFloat32(inputData, inputShape, + padding_left, padding_right, + padding_top, padding_bottom, + stride_width, stride_height, + filter_width, filter_height, + activation, + outputData, outputShape); + EXPECT_EQ(bret, true); + + float expectData[] = { + 5.0f, 6.0f, + 8.0f, 9.0f + }; + bret = util::compareData(outputData, expectData, outputShape); + EXPECT_EQ(bret, true); +} + TEST(KernelACL_TC, averagePoolFloat32_3x3to1x1) { float inputData[9]; @@ -79,3 +118,42 @@ TEST(KernelACL_TC, averagePoolFloat32_3x3to1x1) bret = util::compareData(outputData, expectData, outputShape); EXPECT_EQ(bret, true); } + +TEST(KernelACL_TC, averagePoolFloat32_3x3to2x2) +{ + float inputData[9]; + const android::nn::Shape inputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 }; + int32_t padding_left = 0; + int32_t padding_right = 0; + int32_t padding_top = 0; + int32_t padding_bottom = 0; + int32_t stride_width = 1; + int32_t stride_height = 1; + int32_t filter_width = 2; + int32_t filter_height = 2; + + float outputData[4]; + const android::nn::Shape outputShape = { OperandType::FLOAT32, {1,2,2,1}, 1.0, 0 }; + bool bret; + + util::initData_Increasing(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0); + util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0); + + int32_t activation = ANEURALNETWORKS_FUSED_NONE; + + bret = averagePoolFloat32(inputData, inputShape, + padding_left, padding_right, + padding_top, padding_bottom, + stride_width, stride_height, + filter_width, filter_height, + activation, + outputData, outputShape); + EXPECT_EQ(bret, true); + + float expectData[] = { + 3.0f, 4.0f, + 6.0f, 7.0f + }; + bret = util::compareData(outputData, expectData, outputShape); + EXPECT_EQ(bret, true); +} diff --git a/src/kernel/acl/src/neon/Pooling.test.cpp b/src/kernel/acl/src/neon/Pooling.test.cpp index 8296add..dd56025 100644 --- a/src/kernel/acl/src/neon/Pooling.test.cpp +++ b/src/kernel/acl/src/neon/Pooling.test.cpp @@ -44,6 +44,45 @@ TEST(KernelACL_TC, neon_maxPoolFloat32_3x3to1x1) EXPECT_EQ(bret, true); } +TEST(KernelACL_TC, neon_maxPoolFloat32_3x3to2x2) +{ + float inputData[9]; + const android::nn::Shape inputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 }; + int32_t padding_left = 0; + int32_t padding_right = 1; + int32_t padding_top = 0; + int32_t padding_bottom = 1; + int32_t stride_width = 2; + int32_t stride_height = 2; + int32_t filter_width = 2; + int32_t filter_height = 2; + + float outputData[4]; + const android::nn::Shape outputShape = { OperandType::FLOAT32, {1,2,2,1}, 1.0, 0 }; + bool bret; + + util::initData_Increasing(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0); + util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0); + + int32_t activation = ANEURALNETWORKS_FUSED_NONE; + + bret = neon::maxPoolFloat32(inputData, inputShape, + padding_left, padding_right, + padding_top, padding_bottom, + stride_width, stride_height, + filter_width, filter_height, + activation, + outputData, outputShape); + EXPECT_EQ(bret, true); + + float expectData[] = { + 5.0f, 6.0f, + 8.0f, 9.0f + }; + bret = util::compareData(outputData, expectData, outputShape); + EXPECT_EQ(bret, true); +} + TEST(KernelACL_TC, neon_averagePoolFloat32_3x3to1x1) { float inputData[9]; @@ -79,3 +118,42 @@ TEST(KernelACL_TC, neon_averagePoolFloat32_3x3to1x1) bret = util::compareData(outputData, expectData, outputShape); EXPECT_EQ(bret, true); } + +TEST(KernelACL_TC, neon_averagePoolFloat32_3x3to2x2) +{ + float inputData[9]; + const android::nn::Shape inputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 }; + int32_t padding_left = 0; + int32_t padding_right = 0; + int32_t padding_top = 0; + int32_t padding_bottom = 0; + int32_t stride_width = 1; + int32_t stride_height = 1; + int32_t filter_width = 2; + int32_t filter_height = 2; + + float outputData[4]; + const android::nn::Shape outputShape = { OperandType::FLOAT32, {1,2,2,1}, 1.0, 0 }; + bool bret; + + util::initData_Increasing(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0); + util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0); + + int32_t activation = ANEURALNETWORKS_FUSED_NONE; + + bret = neon::averagePoolFloat32(inputData, inputShape, + padding_left, padding_right, + padding_top, padding_bottom, + stride_width, stride_height, + filter_width, filter_height, + activation, + outputData, outputShape); + EXPECT_EQ(bret, true); + + float expectData[] = { + 3.0f, 4.0f, + 6.0f, 7.0f + }; + bret = util::compareData(outputData, expectData, outputShape); + EXPECT_EQ(bret, true); +} -- 2.7.4