blob: 241481b8badbe66d9ce4eee8544f514488d2edcf [file] [log] [blame]
Giorgio Arena945ae9e2021-10-13 11:13:04 +01001/*
2 * Copyright (c) 2021 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_CLCONVOLUTION3DLAYER_H
25#define ARM_COMPUTE_CLCONVOLUTION3DLAYER_H
26
27#include "arm_compute/runtime/IFunction.h"
28
29#include <memory>
30
31namespace arm_compute
32{
33class CLCompileContext;
34class ICLTensor;
35class ITensorInfo;
36struct Conv3dInfo;
37class Status;
38
39/** Basic function to compute the convolution3d layer. This function calls the following OpenCL kernels/functions:
40 *
41 * -# @ref opencl::ClDirectConv3d
42 */
43class CLConv3D : public IFunction
44{
45public:
46 /** Construtor */
47 CLConv3D();
48 /** Destructor */
49 ~CLConv3D();
50 /** Prevent instances of this class from being copied (As this class contains pointers) */
51 CLConv3D(const CLConv3D &) = delete;
52 /** Default move constructor */
53 CLConv3D(CLConv3D &&) = default;
54 /** Prevent instances of this class from being copied (As this class contains pointers) */
55 CLConv3D &operator=(const CLConv3D &) = delete;
56 /** Default move assignment operator */
57 CLConv3D &operator=(CLConv3D &&) = default;
58 /** Set the src and dst tensors.
59 *
60 * Valid data layouts:
61 * - NDHWC
62 *
63 * Valid data type configurations:
64 * |src0 |src1 |src2 |dst |
65 * |:--------------|:--------------|:------|:--------------|
66 * |F16 |F16 |F16 |F16 |
67 * |F32 |F32 |F32 |F32 |
68 *
69 * @param[in] compile_context The compile context to be used.
70 * @param[in] src Source tensor. 4 lower dimensions represent a single src [IFM, width, height, depth],
71 * while every optional dimension from 5 and above represent a batch of srcs.
72 * @param[in] weights Weights tensor. Weights are 5D tensor with dimensions [OFM, IFM, kernel_w, kernel_h, kernel_d].
73 * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM].
74 * @param[out] dst Destination tensor. 4 lower dimensions represent a single dst [OFM, width, height, depth], while the rest represent batch of dsts.
75 * @param[in] conv3d_info Contains strides, padding, rounding, activation, dilation and fast math information. Activation and fast math are currently unused.
76 *
77 */
78 void configure(const CLCompileContext &compile_context, const ICLTensor *src, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *dst, const Conv3dInfo &conv3d_info);
79 /** Set the src and dst tensors.
80 *
81 * Similar to CLConv3D::configure() but using the default compile context
82 *
83 */
84 void configure(const ICLTensor *src, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *dst, const Conv3dInfo &conv3d_info);
85 /** Static function to check if given info will lead to a valid configuration of @ref CLConv3D
86 *
87 * Similar to CLConv3D::configure()
88 *
89 * @return a status
90 */
91 static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const Conv3dInfo &conv3d_info);
92
93 // Inherited methods overridden:
94 void run() override;
95
96private:
97 struct Impl;
98 std::unique_ptr<Impl> _impl;
99};
100}
101#endif /* ARM_COMPUTE_CLCONVOLUTION3DLAYER_H */