This commit introduces the first version of reshape layer using ACL.
Unit test will be added more in later commits.
Signed-off-by: Junghyun Kim <jh0822.kim@samsung.com>
"src/IO_accessor.cpp"
"src/cl/Conv2D_acl.cpp"
"src/cl/FullyConnected.cpp"
+ "src/cl/Reshape.cpp"
)
add_library(${LIB_KERNELACL} SHARED ${KERNELACL_SRCS})
"src/util.cpp"
"src/gtest_env.cpp"
"src/cl/FullyConnected.test.cpp"
+ "src/cl/Reshape.test.cpp"
)
add_executable(${LIB_KERNELACL_TEST} ${KERNELACL_TEST_SRCS})
--- /dev/null
+#include <OperationsUtils.h>
+#include <arm_compute/core/TensorShape.h>
+#include <arm_compute/core/TensorInfo.h>
+
+// TODO: fix include path in CMakeFiles
+#include "../IO_accessor.h"
+
+namespace android {
+namespace nn {
+
+// TODO remove from this source and use it from runtime
+uint32_t getSizeOfDimension(const Shape& shape, uint32_t dimensionIdx);
+
+} // namespace nn
+} // namespace android
+
+namespace nnfw {
+namespace kernel {
+namespace acl {
+
+arm_compute::TensorShape fromNNShape(const android::nn::Shape& shape);
+
+bool reshapeGeneric(const void* inputData, const android::nn::Shape& inputShape,
+ void* outputData, const android::nn::Shape& outputShape) {
+
+ auto input_shape = fromNNShape(inputShape);
+ auto output_shape = fromNNShape(outputShape);
+
+ arm_compute::CLTensor input, output;
+
+ input.allocator()->init(arm_compute::TensorInfo(input_shape, arm_compute::Format::F32));
+ output.allocator()->init(arm_compute::TensorInfo(output_shape, arm_compute::Format::F32));
+
+ arm_compute::CLReshapeLayer l;
+
+ l.configure(&input, &output);
+
+ input.allocator()->allocate();
+ output.allocator()->allocate();
+
+ TensorAccess<InputAccessor>(input, (float*)inputData, inputShape);
+
+ l.run();
+
+ arm_compute::CLScheduler::get().sync();
+
+ TensorAccess<OutputAccessor>(output, (float*)outputData, outputShape);
+
+ return true;
+}
+
+} // namespace acl
+} // namespace kernel
+} // namespace nnfw
--- /dev/null
+#include <gtest/gtest.h>
+#include <OperationsUtils.h>
+#include <kernel/acl/nnfw_kernel_acl.h>
+
+// TODO: fix include path in CMakeFiles
+#include "../util.h"
+
+namespace nnfw {
+namespace kernel {
+namespace acl {
+
+bool reshapeGeneric(const void* inputData, const android::nn::Shape& inputShape,
+ void* outputData, const android::nn::Shape& outputShape);
+} // namespace acl
+} // namespace kernel
+} // namespace nnfw
+
+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);
+
+}