blob: ef73fa8e6182bfcc0939a8ce49c3cbdab11523cb [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +00002 * Copyright (c) 2017-2020 ARM Limited.
Anthony Barbier7068f992017-10-26 15:23:08 +01003 *
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 Zhou53a6ec52017-11-14 15:14:25 +080026#include "arm_compute/core/GLES_COMPUTE/IGCTensor.h"
Anthony Barbier7068f992017-10-26 15:23:08 +010027#include "arm_compute/core/GLES_COMPUTE/kernels/GCPoolingLayerKernel.h"
Frank Lei4406fd62018-02-01 14:47:14 +080028#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
29
Anthony Barbier7068f992017-10-26 15:23:08 +010030#include "support/ToolchainSupport.h"
31
32using namespace arm_compute;
33
Frank Lei4406fd62018-02-01 14:47:14 +080034GCPoolingLayer::GCPoolingLayer()
35 : _kernel(nullptr), _border_handler(), _shift_handler()
36{
37}
38
Anthony Barbier7068f992017-10-26 15:23:08 +010039void 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
Sang-Hoon Park0cb3da62020-01-15 12:39:56 +000047 BorderMode border_mode = (PoolingType::MAX == pool_info.pool_type) ? BorderMode::REPLICATE : BorderMode::CONSTANT;
Anthony Barbier7068f992017-10-26 15:23:08 +010048 _border_handler.configure(input, _kernel->border_size(), border_mode, PixelValue(0.0f));
Frank Lei4406fd62018-02-01 14:47:14 +080049
50 _shift_handler.configure(input);
Anthony Barbier7068f992017-10-26 15:23:08 +010051}
Xinghang Zhou53a6ec52017-11-14 15:14:25 +080052
53Status GCPoolingLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info)
54{
55 return GCPoolingLayerKernel::validate(input, output, pool_info);
Frank Lei4406fd62018-02-01 14:47:14 +080056}
57
58void 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}