From aab8d9e91d16ee39b11b5eaa231937c600a1109d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=A0=95=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 20 Apr 2018 10:19:11 +0900 Subject: [PATCH] Unify NEON and OpenCL versions of Reshape unit test (#813) - extract common features to `src/Reshape.test.h` - implement different parts into `neon/Reshape.test.cpp` and `cl/Reshape.test.cpp` Signed-off-by: Junghyun Kim --- src/kernel/acl/src/Reshape.test.h | 35 ++++++++++++++++++++++++++++++++ src/kernel/acl/src/cl/Reshape.test.cpp | 29 +++----------------------- src/kernel/acl/src/neon/Reshape.test.cpp | 29 +++----------------------- 3 files changed, 41 insertions(+), 52 deletions(-) create mode 100644 src/kernel/acl/src/Reshape.test.h diff --git a/src/kernel/acl/src/Reshape.test.h b/src/kernel/acl/src/Reshape.test.h new file mode 100644 index 0000000..bca8d8f --- /dev/null +++ b/src/kernel/acl/src/Reshape.test.h @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +// TODO: fix include path in CMakeFiles +#include "util.h" + +#ifndef ACL_TEST +#error "ACL_TEST should be defined first!" +#endif // ACL_TEST + +#ifndef ACL_CORE_FUNC_NAME +#error "ACL_CORE_FUNC_NAME should be defined first!" +#endif // ACL_CORE_FUNC_NAME + +using namespace nnfw::kernel::acl; + +ACL_TEST(KernelACL_TC, reshape_1) { + const android::nn::Shape inputShape = {OperandType::FLOAT32, {1,1,9,1}, 1.0, 0}; + float inputData[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; + + const android::nn::Shape outputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 }; + float outputData[9] = {0}; + + bool bret = ACL_CORE_FUNC_NAME(inputData, inputShape, + outputData, outputShape); + + EXPECT_EQ(bret, true); + + float expectData[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; + bret = util::compareData(outputData, expectData, outputShape); + EXPECT_EQ(bret, true); + +} diff --git a/src/kernel/acl/src/cl/Reshape.test.cpp b/src/kernel/acl/src/cl/Reshape.test.cpp index 83212cb..8faecbb 100644 --- a/src/kernel/acl/src/cl/Reshape.test.cpp +++ b/src/kernel/acl/src/cl/Reshape.test.cpp @@ -1,27 +1,4 @@ -#include -#include -#include -#include +#define ACL_CORE_FUNC_NAME reshapeGeneric +#define ACL_TEST(tc, t) TEST(tc, cl_##t) -// TODO: fix include path in CMakeFiles -#include "../util.h" - -using namespace nnfw::kernel::acl; - -TEST(KernelACL_TC, reshape_1) { - const android::nn::Shape inputShape = {OperandType::FLOAT32, {1,1,9,1}, 1.0, 0}; - float inputData[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; - - const android::nn::Shape outputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 }; - float outputData[9] = {0}; - - bool bret = reshapeGeneric(inputData, inputShape, - outputData, outputShape); - - EXPECT_EQ(bret, true); - - float expectData[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; - bret = util::compareData(outputData, expectData, outputShape); - EXPECT_EQ(bret, true); - -} +#include "../Reshape.test.h" diff --git a/src/kernel/acl/src/neon/Reshape.test.cpp b/src/kernel/acl/src/neon/Reshape.test.cpp index a3dddcf..9b0705f 100644 --- a/src/kernel/acl/src/neon/Reshape.test.cpp +++ b/src/kernel/acl/src/neon/Reshape.test.cpp @@ -1,27 +1,4 @@ -#include -#include -#include -#include +#define ACL_CORE_FUNC_NAME neon::reshapeGeneric +#define ACL_TEST(tc, t) TEST(tc, neon_##t) -// TODO: fix include path in CMakeFiles -#include "../util.h" - -using namespace nnfw::kernel::acl; - -TEST(KernelACL_TC, neon_reshape_1) { - const android::nn::Shape inputShape = {OperandType::FLOAT32, {1,1,9,1}, 1.0, 0}; - float inputData[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; - - const android::nn::Shape outputShape = { OperandType::FLOAT32, {1,3,3,1}, 1.0, 0 }; - float outputData[9] = {0}; - - bool bret = neon::reshapeGeneric(inputData, inputShape, - outputData, outputShape); - - EXPECT_EQ(bret, true); - - float expectData[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; - bret = util::compareData(outputData, expectData, outputShape); - EXPECT_EQ(bret, true); - -} +#include "../Reshape.test.h" -- 2.7.4