From 156fcf3f36f6168e47d65db167bba3af5037e3d9 Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Fri, 9 Mar 2018 15:30:43 +0000 Subject: COMPMID-802 Add NHWC data format support for NEON im2col. Change-Id: I86e678179106a2b83d1c6a7cfe562df91b0f9eb2 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/124000 Tested-by: Jenkins Reviewed-by: Pablo Tello --- src/runtime/CL/functions/CLFullyConnectedLayer.cpp | 4 ++-- .../NEON/functions/NEFullyConnectedLayer.cpp | 4 ++-- src/runtime/NEON/functions/NEIm2Col.cpp | 25 ++++++++++++++++------ 3 files changed, 22 insertions(+), 11 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp index 676706fb17..5dd1f00fa6 100644 --- a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp +++ b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp @@ -114,7 +114,7 @@ void CLFullyConnectedLayer::configure_conv_fc(const ICLTensor *input, const ICLT // If the fully connected layer is called after a convolution layer, the input tensor must be linearized // Initialize output tensor for im2col - TensorShape shape_im2col = compute_im2col_shape(input->info()); + TensorShape shape_im2col = compute_im2col_fc_shape(input->info()); _im2col_output.allocator()->init(input->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(shape_im2col)); // Configure im2col kernel @@ -244,7 +244,7 @@ Status CLFullyConnectedLayer::validate(const ITensorInfo *input, const ITensorIn bool is_quantized = is_data_type_quantized_asymmetric(input->data_type()); const GPUTarget gpu_target = CLScheduler::get().target(); - const ITensorInfo &im2col_input = TensorInfo(input->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_im2col_shape(input))); + const ITensorInfo &im2col_input = TensorInfo(input->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_im2col_fc_shape(input))); const ITensorInfo &reshaped_weights = TensorInfo(weights->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_transposed_shape(*weights))); const ITensorInfo &gemmlowp_output = TensorInfo(output->clone()->set_is_resizable(true).reset_padding().set_data_type(DataType::S32)); diff --git a/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp b/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp index b310ad35e3..958d081fd2 100644 --- a/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp +++ b/src/runtime/NEON/functions/NEFullyConnectedLayer.cpp @@ -188,7 +188,7 @@ void NEFullyConnectedLayer::configure(const ITensor *input, const ITensor *weigh if(_linearize_input) { - _im2col_output.allocator()->init(input->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_im2col_shape(input->info(), num_input_dimensions))); + _im2col_output.allocator()->init(input->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_im2col_fc_shape(input->info(), num_input_dimensions))); // Configure im2col kernel _memory_group.manage(&_im2col_output); @@ -288,7 +288,7 @@ Status NEFullyConnectedLayer::validate(const ITensorInfo *input, const ITensorIn if(linearize_input) { - im2col_output->set_tensor_shape(compute_im2col_shape(input, num_input_dimensions)); + im2col_output->set_tensor_shape(compute_im2col_fc_shape(input, num_input_dimensions)); ARM_COMPUTE_RETURN_ON_ERROR(NEIm2ColKernel::validate(input, im2col_output.get(), Size2D(1, 1), PadStrideInfo(1, 1, 0, 0), false, true)); diff --git a/src/runtime/NEON/functions/NEIm2Col.cpp b/src/runtime/NEON/functions/NEIm2Col.cpp index b962db9144..6b95cb0256 100644 --- a/src/runtime/NEON/functions/NEIm2Col.cpp +++ b/src/runtime/NEON/functions/NEIm2Col.cpp @@ -23,19 +23,30 @@ */ #include "arm_compute/runtime/NEON/functions/NEIm2Col.h" -#include "arm_compute/core/NEON/kernels/NEIm2ColKernel.h" +#include "arm_compute/core/TensorInfo.h" +#include "arm_compute/runtime/NEON/NEScheduler.h" #include "support/ToolchainSupport.h" using namespace arm_compute; -void NEIm2Col::configure(const ITensor *input, ITensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, bool is_fully_connected) +NEIm2Col::NEIm2Col() + : _kernel(), _y_dim(1) { - auto k = arm_compute::support::cpp14::make_unique(); - k->configure(input, output, kernel_dims, conv_info, has_bias, is_fully_connected); - _kernel = std::move(k); } -Status NEIm2Col::validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, bool is_fully_connected) +void NEIm2Col::configure(const ITensor *input, ITensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, bool is_fully_connected, bool is_flatten) { - return NEIm2ColKernel::validate(input, output, kernel_dims, conv_info, has_bias, is_fully_connected); + _y_dim = get_data_layout_dimension_index(input->info()->data_layout(), DataLayoutDimension::HEIGHT); + + _kernel.configure(input, output, kernel_dims, conv_info, has_bias, is_fully_connected, is_flatten); +} + +Status NEIm2Col::validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, bool is_fully_connected, bool is_flatten) +{ + return NEIm2ColKernel::validate(input, output, kernel_dims, conv_info, has_bias, is_fully_connected, is_flatten); +} + +void NEIm2Col::run() +{ + NEScheduler::get().schedule(&_kernel, _y_dim); } -- cgit v1.2.1