From 0e4556ce45cb857ac44354df73f8228475f3ad3c Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 20 Dec 2019 10:29:12 +0000 Subject: COMPMID-2819: Retain data layout in NESpaceToDepth and NEDepthToSpace Retain layout from configuration to execution as following configuration might alter tensor meta-data in client code. Signed-off-by: Georgios Pinitas Change-Id: Ifdbb285809956b966ea534ab3ab231911a307cc0 Reviewed-on: https://review.mlplatform.org/c/2512 Reviewed-by: Pablo Marquez Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- arm_compute/core/NEON/kernels/NEDepthToSpaceLayerKernel.h | 1 + arm_compute/core/NEON/kernels/NESpaceToDepthLayerKernel.h | 2 +- src/core/NEON/kernels/NEDepthToSpaceLayerKernel.cpp | 7 ++++--- src/core/NEON/kernels/NESpaceToDepthLayerKernel.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arm_compute/core/NEON/kernels/NEDepthToSpaceLayerKernel.h b/arm_compute/core/NEON/kernels/NEDepthToSpaceLayerKernel.h index 3129ea9fb9..0b645887ee 100644 --- a/arm_compute/core/NEON/kernels/NEDepthToSpaceLayerKernel.h +++ b/arm_compute/core/NEON/kernels/NEDepthToSpaceLayerKernel.h @@ -75,6 +75,7 @@ private: const ITensor *_input; /**< Source tensor */ ITensor *_output; /**< Destination tensor */ int32_t _block_shape; /**< Block shape */ + DataLayout _data_layout; /**< Data layout of the operation */ }; } // namespace arm_compute #endif /* ARM_COMPUTE_NEDEPTHTOSPACELAYERKERNEL_H */ diff --git a/arm_compute/core/NEON/kernels/NESpaceToDepthLayerKernel.h b/arm_compute/core/NEON/kernels/NESpaceToDepthLayerKernel.h index 9fce338161..e0c22e65fb 100644 --- a/arm_compute/core/NEON/kernels/NESpaceToDepthLayerKernel.h +++ b/arm_compute/core/NEON/kernels/NESpaceToDepthLayerKernel.h @@ -75,7 +75,7 @@ private: const ITensor *_input; /**< Source tensor */ ITensor *_output; /**< Destination tensor */ int32_t _block_shape; /**< Block shape */ - DataLayout _data_layout; + DataLayout _data_layout; /**< Data layout of the operation */ }; } // namespace arm_compute #endif /* ARM_COMPUTE_NESPACETODEPTHLAYERKERNEL_H */ diff --git a/src/core/NEON/kernels/NEDepthToSpaceLayerKernel.cpp b/src/core/NEON/kernels/NEDepthToSpaceLayerKernel.cpp index b51d0d66c5..3641a8440d 100644 --- a/src/core/NEON/kernels/NEDepthToSpaceLayerKernel.cpp +++ b/src/core/NEON/kernels/NEDepthToSpaceLayerKernel.cpp @@ -64,7 +64,7 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, i } // namespace NEDepthToSpaceLayerKernel::NEDepthToSpaceLayerKernel() - : _input(nullptr), _output(nullptr), _block_shape() + : _input(nullptr), _output(nullptr), _block_shape(), _data_layout(DataLayout::UNKNOWN) { } @@ -81,6 +81,7 @@ void NEDepthToSpaceLayerKernel::configure(const ITensor *input, ITensor *output, _input = input; _output = output; _block_shape = block_shape; + _data_layout = input->info()->data_layout(); // Configure kernel window Window win = calculate_max_window(*input->info(), Steps()); @@ -100,7 +101,7 @@ void NEDepthToSpaceLayerKernel::run(const Window &window, const ThreadInfo &info ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICPPKernel::window(), window); - const int idx_channel = get_data_layout_dimension_index(_input->info()->data_layout(), DataLayoutDimension::CHANNEL); + const int idx_channel = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL); const int depth_size = _input->info()->dimension(idx_channel); const int r = (depth_size / (_block_shape * _block_shape)); const int element_size = _input->info()->element_size(); @@ -113,7 +114,7 @@ void NEDepthToSpaceLayerKernel::run(const Window &window, const ThreadInfo &info slice_out.set(Window::DimZ, Window::Dimension(0, 0, 0)); // Main loop for NCHW and NHWC - if(_input->info()->data_layout() == DataLayout::NCHW) + if(_data_layout == DataLayout::NCHW) { Window slice_in = window.first_slice_window_2D(); do diff --git a/src/core/NEON/kernels/NESpaceToDepthLayerKernel.cpp b/src/core/NEON/kernels/NESpaceToDepthLayerKernel.cpp index bc27a3c76a..4087d8c8d3 100644 --- a/src/core/NEON/kernels/NESpaceToDepthLayerKernel.cpp +++ b/src/core/NEON/kernels/NESpaceToDepthLayerKernel.cpp @@ -67,7 +67,7 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, i } // namespace NESpaceToDepthLayerKernel::NESpaceToDepthLayerKernel() - : _input(nullptr), _output(nullptr), _block_shape(),_data_layout(DataLayout::UNKNOWN) + : _input(nullptr), _output(nullptr), _block_shape(), _data_layout(DataLayout::UNKNOWN) { } @@ -102,8 +102,8 @@ void NESpaceToDepthLayerKernel::run(const Window &window, const ThreadInfo &info ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICPPKernel::window(), window); - const int channel_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL); - const int element_size = _input->info()->element_size(); + const int channel_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL); + const int element_size = _input->info()->element_size(); const size_t channel_size = _input->info()->dimension(channel_idx); @@ -112,7 +112,7 @@ void NESpaceToDepthLayerKernel::run(const Window &window, const ThreadInfo &info int batch_id = 0; // Main loop for NCHW and NHWC - if(_output->info()->data_layout() == DataLayout::NCHW) + if(_data_layout == DataLayout::NCHW) { do { -- cgit v1.2.1