Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 1 | /* |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 2 | * Copyright (c) 2019-2020 Arm Limited. |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [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 | */ |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 24 | #ifndef SRC_ASSEMBLY_DEPTHWISE_CONVOLUTION_ASSEMBLY_WRAPPER_KERNEL_H |
| 25 | #define SRC_ASSEMBLY_DEPTHWISE_CONVOLUTION_ASSEMBLY_WRAPPER_KERNEL_H |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 26 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/Utils.h" |
| 28 | #include "arm_compute/core/Validate.h" |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 29 | #include "src/core/NEON/INEKernel.h" |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 30 | |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 31 | #include "src/core/NEON/kernels/convolution/depthwise/depthwise.hpp" |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | // Forward declarations |
| 36 | class ITensor; |
| 37 | |
| 38 | /** This class is a wrapper for the depthwise convolution assembly kernels. */ |
| 39 | class NEDepthwiseConvolutionAssemblyKernelWrapper final : public INEKernel |
| 40 | { |
| 41 | public: |
| 42 | const char *name() const override |
| 43 | { |
| 44 | return "NEDepthwiseConvolutionAssemblyKernelWrapper"; |
| 45 | } |
| 46 | |
| 47 | /** Default constructor */ |
| 48 | NEDepthwiseConvolutionAssemblyKernelWrapper() |
| 49 | : _kernel(nullptr) |
| 50 | { |
| 51 | } |
| 52 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 53 | NEDepthwiseConvolutionAssemblyKernelWrapper(const NEDepthwiseConvolutionAssemblyKernelWrapper &) = delete; |
| 54 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 55 | NEDepthwiseConvolutionAssemblyKernelWrapper &operator=(const NEDepthwiseConvolutionAssemblyKernelWrapper &) = delete; |
| 56 | /** Default Move Constructor. */ |
| 57 | NEDepthwiseConvolutionAssemblyKernelWrapper(NEDepthwiseConvolutionAssemblyKernelWrapper &&) = default; |
| 58 | /** Default move assignment operator */ |
| 59 | NEDepthwiseConvolutionAssemblyKernelWrapper &operator=(NEDepthwiseConvolutionAssemblyKernelWrapper &&) = default; |
| 60 | |
| 61 | /** Initialise the kernel's input and output. |
| 62 | * |
| 63 | * @param[in] kernel Pointer to an assembly kernel implementation. |
| 64 | */ |
| 65 | void configure(depthwise::IDepthwiseConvolution *kernel) |
| 66 | { |
| 67 | ARM_COMPUTE_ERROR_ON_NULLPTR((reinterpret_cast<void *>(kernel))); |
| 68 | _kernel = kernel; |
| 69 | Window win; |
| 70 | win.set(Window::DimX, Window::Dimension(0, _kernel->get_window(), 1)); |
| 71 | INEKernel::configure(win); |
| 72 | } |
| 73 | |
| 74 | // Inherited methods overridden: |
| 75 | void run(const Window &window, const ThreadInfo &info) override |
| 76 | { |
| 77 | ARM_COMPUTE_ERROR_ON_NULLPTR((reinterpret_cast<void *>(_kernel))); |
| 78 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 79 | auto first = window.x().start(); |
| 80 | auto last = window.x().end(); |
| 81 | _kernel->run(first, last, info.thread_id); |
| 82 | } |
| 83 | |
| 84 | private: |
| 85 | depthwise::IDepthwiseConvolution *_kernel; |
| 86 | }; |
| 87 | } // namespace arm_compute |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 88 | #endif /* SRC_ASSEMBLY_DEPTHWISE_CONVOLUTION_ASSEMBLY_WRAPPER_KERNEL_H */ |