blob: d6a335c1ec13954dde34f18875c1fbfd57e6f7f4 [file] [log] [blame]
Kaizen8938bd32017-09-28 14:38:23 +01001/*
2 * Copyright (c) 2017 ARM Limited.
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/CL/functions/CLDirectConvolutionLayer.h"
25
Anthony Barbier8140e1e2017-12-14 23:48:46 +000026#include "arm_compute/core/CL/ICLTensor.h"
Kaizen8938bd32017-09-28 14:38:23 +010027#include "arm_compute/core/CL/kernels/CLDirectConvolutionLayerKernel.h"
28#include "arm_compute/core/PixelValue.h"
29#include "arm_compute/core/Utils.h"
30#include "arm_compute/core/Validate.h"
31#include "arm_compute/runtime/CL/CLScheduler.h"
32
33using namespace arm_compute;
34
35CLDirectConvolutionLayer::CLDirectConvolutionLayer()
36 : _direct_conv_kernel(), _input_border_handler()
37{
38}
39
40void CLDirectConvolutionLayer::configure(ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info)
41{
42 // Set GPU target
43 _direct_conv_kernel.set_target(CLScheduler::get().target());
44
45 // Configure direct convolution
46 _direct_conv_kernel.configure(input, weights, biases, output, conv_info);
47
48 // Configure border handler
Anthony Barbier8140e1e2017-12-14 23:48:46 +000049 PixelValue &&zero_value(0.f);
50 if(is_data_type_quantized_asymmetric(input->info()->data_type()))
51 {
52 zero_value = PixelValue(static_cast<uint8_t>(input->info()->quantization_info().offset));
53 }
54 _input_border_handler.configure(input, _direct_conv_kernel.border_size(), BorderMode::CONSTANT, zero_value);
55}
56
57Status CLDirectConvolutionLayer::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info)
58{
59 return CLDirectConvolutionLayerKernel::validate(input, weights, biases, output, conv_info, CLScheduler::get().target());
Kaizen8938bd32017-09-28 14:38:23 +010060}
61
62void CLDirectConvolutionLayer::run()
63{
64 // Run border handler
65 CLScheduler::get().enqueue(_input_border_handler, false);
66
67 // Run direct convolution
68 CLScheduler::get().enqueue(_direct_conv_kernel);
69}