blob: 8a9fb82b4a83277ff62c3de4362403c56a015bd9 [file] [log] [blame]
Georgios Pinitas47d39dc2019-03-11 14:03:23 +00001/*
2 * Copyright (c) 2019 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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_ASSEMBLY_DEPTHWISE_CONVOLUTION_ASSEMBLY_WRAPPER_KERNEL_H
25#define ARM_COMPUTE_ASSEMBLY_DEPTHWISE_CONVOLUTION_ASSEMBLY_WRAPPER_KERNEL_H
Georgios Pinitas47d39dc2019-03-11 14:03:23 +000026
27#include "arm_compute/core/NEON/INEKernel.h"
28#include "arm_compute/core/Utils.h"
29#include "arm_compute/core/Validate.h"
30
31#include "arm_compute/core/NEON/kernels/convolution/depthwise/depthwise.hpp"
32
33namespace arm_compute
34{
35// Forward declarations
36class ITensor;
37
38/** This class is a wrapper for the depthwise convolution assembly kernels. */
39class NEDepthwiseConvolutionAssemblyKernelWrapper final : public INEKernel
40{
41public:
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
84private:
85 depthwise::IDepthwiseConvolution *_kernel;
86};
87} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000088#endif /* ARM_COMPUTE_ASSEMBLY_DEPTHWISE_CONVOLUTION_ASSEMBLY_WRAPPER_KERNEL_H */