Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 1 | /* |
Frank Lei | 4406fd6 | 2018-02-01 14:47:14 +0800 | [diff] [blame^] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/runtime/GLES_COMPUTE/functions/GCPoolingLayer.h" |
| 25 | |
Xinghang Zhou | 53a6ec5 | 2017-11-14 15:14:25 +0800 | [diff] [blame] | 26 | #include "arm_compute/core/GLES_COMPUTE/IGCTensor.h" |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/GLES_COMPUTE/kernels/GCPoolingLayerKernel.h" |
Frank Lei | 4406fd6 | 2018-02-01 14:47:14 +0800 | [diff] [blame^] | 28 | #include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h" |
| 29 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 30 | #include "support/ToolchainSupport.h" |
| 31 | |
| 32 | using namespace arm_compute; |
| 33 | |
Frank Lei | 4406fd6 | 2018-02-01 14:47:14 +0800 | [diff] [blame^] | 34 | GCPoolingLayer::GCPoolingLayer() |
| 35 | : _kernel(nullptr), _border_handler(), _shift_handler() |
| 36 | { |
| 37 | } |
| 38 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 39 | void GCPoolingLayer::configure(IGCTensor *input, IGCTensor *output, const PoolingLayerInfo &pool_info) |
| 40 | { |
| 41 | // Configure pooling kernel |
| 42 | auto k = arm_compute::support::cpp14::make_unique<GCPoolingLayerKernel>(); |
| 43 | k->configure(input, output, pool_info); |
| 44 | _kernel = std::move(k); |
| 45 | |
| 46 | // Configure border depending on operation required |
| 47 | BorderMode border_mode = (PoolingType::MAX == pool_info.pool_type()) ? BorderMode::REPLICATE : BorderMode::CONSTANT; |
| 48 | _border_handler.configure(input, _kernel->border_size(), border_mode, PixelValue(0.0f)); |
Frank Lei | 4406fd6 | 2018-02-01 14:47:14 +0800 | [diff] [blame^] | 49 | |
| 50 | _shift_handler.configure(input); |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 51 | } |
Xinghang Zhou | 53a6ec5 | 2017-11-14 15:14:25 +0800 | [diff] [blame] | 52 | |
| 53 | Status GCPoolingLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info) |
| 54 | { |
| 55 | return GCPoolingLayerKernel::validate(input, output, pool_info); |
Frank Lei | 4406fd6 | 2018-02-01 14:47:14 +0800 | [diff] [blame^] | 56 | } |
| 57 | |
| 58 | void GCPoolingLayer::run() |
| 59 | { |
| 60 | GCScheduler::get().dispatch(_shift_handler, false); |
| 61 | GCScheduler::get().memory_barrier(); |
| 62 | GCScheduler::get().dispatch(_border_handler, false); |
| 63 | GCScheduler::get().memory_barrier(); |
| 64 | GCScheduler::get().dispatch(*_kernel); |
| 65 | } |