1 /* 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 31 namespace arm_compute 32 { 33 class CLCompileContext; 34 class ICLTensor; 35 class ITensorInfo; 36 struct Conv3dInfo; 37 class Status; 38 39 /** Basic function to compute the convolution3d layer. This function calls the following OpenCL kernels/functions: 40 * 41 * -# @ref opencl::ClDirectConv3d 42 */ 43 class CLConv3D : public IFunction 44 { 45 public: 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 * |QASYMM8 |QASYMM8 |S32 |QASYMM8 | 69 * |QASYMM8_SIGNED |QASYMM8_SIGNED |S32 |QASYMM8_SIGNED | 70 * 71 * @param[in] compile_context The compile context to be used. 72 * @param[in] src Source tensor. 4 lower dimensions represent a single src [IFM, width, height, depth], 73 * while every optional dimension from 5 and above represent a batch of srcs. 74 * @param[in] weights Weights tensor. Weights are 5D tensor with dimensions [OFM, IFM, kernel_w, kernel_h, kernel_d]. 75 * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. 76 * @param[out] dst Destination tensor. 4 lower dimensions represent a single dst [OFM, width, height, depth], while the rest represent batch of dsts. 77 * @param[in] conv3d_info Contains strides, padding, rounding, activation, dilation and fast math information. Activation and fast math are currently unused. 78 * 79 */ 80 void configure(const CLCompileContext &compile_context, const ICLTensor *src, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *dst, const Conv3dInfo &conv3d_info); 81 /** Set the src and dst tensors. 82 * 83 * Similar to CLConv3D::configure() but using the default compile context 84 * 85 */ 86 void configure(const ICLTensor *src, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *dst, const Conv3dInfo &conv3d_info); 87 /** Static function to check if given info will lead to a valid configuration of @ref CLConv3D 88 * 89 * Similar to CLConv3D::configure() 90 * 91 * @return a status 92 */ 93 static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const Conv3dInfo &conv3d_info); 94 95 // Inherited methods overridden: 96 void run() override; 97 98 private: 99 struct Impl; 100 std::unique_ptr<Impl> _impl; 101 }; 102 } 103 #endif /* ARM_COMPUTE_CLCONVOLUTION3DLAYER_H */ 104