blob: 1eca33ffb76c9119024ff04bdee74708f8ff928f [file] [log] [blame]
Giorgio Arena93a690e2017-08-01 16:09:33 +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 */
Giorgio Arena9fe41442017-08-23 16:36:24 +010024#ifndef __ARM_COMPUTE_CLDEPTHWISECONVOLUTIONKERNEL3x3_H__
25#define __ARM_COMPUTE_CLDEPTHWISECONVOLUTIONKERNEL3x3_H__
Giorgio Arena93a690e2017-08-01 16:09:33 +010026
27#include "arm_compute/core/CL/ICLKernel.h"
28
29namespace arm_compute
30{
31class ICLTensor;
32
33/** Interface for the kernel to run a 3x3 depthwise convolution on a tensor.
34 */
Giorgio Arena9fe41442017-08-23 16:36:24 +010035class CLDepthwiseConvolution3x3Kernel : public ICLKernel
Giorgio Arena93a690e2017-08-01 16:09:33 +010036{
37public:
38 /** Default constructor */
Giorgio Arena9fe41442017-08-23 16:36:24 +010039 CLDepthwiseConvolution3x3Kernel();
Giorgio Arena93a690e2017-08-01 16:09:33 +010040 /** Prevent instances of this class from being copied (As this class contains pointers) */
Giorgio Arena9fe41442017-08-23 16:36:24 +010041 CLDepthwiseConvolution3x3Kernel(const CLDepthwiseConvolution3x3Kernel &) = delete;
Giorgio Arena93a690e2017-08-01 16:09:33 +010042 /** Prevent instances of this class from being copied (As this class contains pointers) */
Giorgio Arena9fe41442017-08-23 16:36:24 +010043 CLDepthwiseConvolution3x3Kernel &operator=(const CLDepthwiseConvolution3x3Kernel &) = delete;
Giorgio Arena93a690e2017-08-01 16:09:33 +010044 /** Default Move Constructor. */
Giorgio Arena9fe41442017-08-23 16:36:24 +010045 CLDepthwiseConvolution3x3Kernel(CLDepthwiseConvolution3x3Kernel &&) = default;
Giorgio Arena93a690e2017-08-01 16:09:33 +010046 /** Default move assignment operator. */
Giorgio Arena9fe41442017-08-23 16:36:24 +010047 CLDepthwiseConvolution3x3Kernel &operator=(CLDepthwiseConvolution3x3Kernel &&) = default;
Giorgio Arena93a690e2017-08-01 16:09:33 +010048 /** Initialize the function's source, destination, conv and border_size.
49 *
50 * @param[in] input Source tensor. DataType supported: F32.
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010051 * @param[in] weights Weights tensor. A 3D tensor with dimensions [3, 3, IFM]. Data type supported: Same as @p input.
52 * @param[in] biases (Optional) Biases tensor. A 1D tensor with dimensions [IFM]. Must be nullptr if not needed.
53 * Data type supported: Same as @p input.
Giorgio Arena82afedf2017-11-15 13:36:15 +000054 * @param[out] output Destination tensor. Data type supported: Same as @p input.
Giorgio Arena9fe41442017-08-23 16:36:24 +010055 * @param[in] conv_info Padding and stride information to use for the convolution.
Giorgio Arena93a690e2017-08-01 16:09:33 +010056 */
Giorgio Arena82afedf2017-11-15 13:36:15 +000057 void configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info);
Giorgio Arena93a690e2017-08-01 16:09:33 +010058
59 // Inherited methods overridden:
60 void run(const Window &window, cl::CommandQueue &queue) override;
61 BorderSize border_size() const override;
62
63private:
64 BorderSize _border_size;
65 const ICLTensor *_input;
66 ICLTensor *_output;
67 const ICLTensor *_weights;
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010068 const ICLTensor *_biases;
Giorgio Arena93a690e2017-08-01 16:09:33 +010069 unsigned int _conv_stride_x;
70 unsigned int _conv_stride_y;
Jaroslaw Rzepecki16cdf892017-10-27 13:15:03 +010071 unsigned int _conv_pad_left;
72 unsigned int _conv_pad_top;
Giorgio Arena93a690e2017-08-01 16:09:33 +010073};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +010074} // namespace arm_compute
Giorgio Arena9fe41442017-08-23 16:36:24 +010075#endif /*__ARM_COMPUTE_CLDEPTHWISECONVOLUTIONKERNEL3x3_H__ */