Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 1 | /* |
| 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 | #ifndef __ARM_COMPUTE_CL_DEPTHWISE_CONVOLUTION_H__ |
| 25 | #define __ARM_COMPUTE_CL_DEPTHWISE_CONVOLUTION_H__ |
| 26 | |
| 27 | #include "arm_compute/core/CL/kernels/CLDepthwiseConvolutionKernel.h" |
| 28 | #include "arm_compute/core/CL/kernels/CLFillBorderKernel.h" |
| 29 | #include "arm_compute/core/Types.h" |
| 30 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 31 | #include "arm_compute/runtime/CL/ICLSimpleFunction.h" |
| 32 | #include "arm_compute/runtime/IFunction.h" |
| 33 | |
| 34 | #include <cstdint> |
| 35 | |
| 36 | namespace arm_compute |
| 37 | { |
| 38 | class ICLTensor; |
| 39 | |
| 40 | /** Basic function to execute depthwise convolution. This function calls the following OpenCL kernels: |
| 41 | * |
| 42 | * -# @ref CLFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE) |
| 43 | * -# @ref CLDepthwiseConvolutionKernel |
| 44 | * |
| 45 | */ |
| 46 | class CLDepthwiseConvolution : public IFunction |
| 47 | { |
| 48 | public: |
| 49 | /** Default constructor */ |
| 50 | CLDepthwiseConvolution(); |
| 51 | /** Initialize the function's source, destination, conv and border_size. |
| 52 | * |
| 53 | * @param[in] input Source tensor. DataType supported: F32. (Written to only for border filling). |
| 54 | * @param[out] output Destination tensor. DataType supported: F32. |
| 55 | * @param[in] weights Weights tensor. These are 3D tensors with dimensions [3, 3, IFM]. Data type supported: Same as @p input. |
| 56 | * @param[in] conv_info Padding and stride information to use for the convolution. DataType supported: F32. |
| 57 | */ |
| 58 | void configure(ICLTensor *input, ICLTensor *output, const ICLTensor *weights, const PadStrideInfo &conv_info); |
| 59 | |
| 60 | // Inherited methods overriden: |
| 61 | void run() override; |
| 62 | |
| 63 | private: |
| 64 | CLDepthwiseConvolutionKernel _kernel; |
| 65 | CLFillBorderKernel _border_handler; |
| 66 | }; |
| 67 | } |
| 68 | #endif /*__ARM_COMPUTE_CL_DEPTHWISE_CONVOLUTION_H__ */ |