1 /* 2 * Copyright (c) 2022-2023 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_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUDEPTHWISECONV2D 25 #define ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUDEPTHWISECONV2D 26 27 #include "arm_compute/dynamic_fusion/sketch/attributes/DepthwiseConv2dAttributes.h" 28 29 namespace arm_compute 30 { 31 namespace experimental 32 { 33 namespace dynamic_fusion 34 { 35 /** Forward declaration */ 36 class GpuWorkloadContext; 37 class GpuWorkloadSketch; 38 39 /** Operator interface. */ 40 class GpuDepthwiseConv2d final 41 { 42 public: 43 /** Attributes are a set of backend-agnostic parameters that define what an operator does */ 44 using Attributes = DepthwiseConv2dAttributes; 45 /** Create an operator and fuse it into the workload sketch. 46 * @note If @ref validate_op() fails, the creation also fails and may throw an error. 47 * @note If @ref validate_op() fails, @p sketch remains unchanged and valid. 48 * 49 * Valid data type configurations: 50 * |src |wei |bia |dst | 51 * |:--------------|:--------------|:--------------|:--------------| 52 * |F16 |F16 |F16 |F16 | 53 * |F32 |F32 |F32 |F32 | 54 * 55 * Valid data layouts: 56 * - NHWC 57 * 58 * @param[in,out] sketch Workload sketch into which the operator will be fused 59 * @param[in] src Source tensor 60 * @param[in] wei Weight tensor 61 * @param[in] bia (Optional) Bias tensor 62 * @param[in] attributes Operator attributes 63 * 64 * @return Pointer for the destination tensor info 65 */ 66 static ITensorInfo *create_op(GpuWorkloadSketch &sketch, 67 ITensorInfo *src, 68 ITensorInfo *wei, 69 ITensorInfo *bia, 70 const Attributes &attributes); 71 72 /** Check if the operator configuration is supported, irrespective of fusion 73 * 74 * @param[in] context Workload context within which the operator is running 75 * @param[in] src Source tensor 76 * @param[in] wei Weight tensor 77 * @param[in] bia (Optional) Bias tensor 78 * @param[in] attributes Operator attributes 79 * 80 * @return Status 81 */ 82 static Status is_supported_op(const GpuWorkloadContext &context, 83 const ITensorInfo *src, 84 const ITensorInfo *wei, 85 const ITensorInfo *bia, 86 const Attributes &attributes); 87 88 /** Check if the operator configuration is supported and if it can be fused into the workload sketch. 89 * 90 * Parameters are similar to @ref GpuDepthwiseConv2d::create_op() 91 * 92 * @return Status 93 */ 94 static Status validate_op(const GpuWorkloadSketch &sketch, 95 const ITensorInfo *src, 96 const ITensorInfo *wei, 97 const ITensorInfo *bia, 98 const Attributes &attributes); 99 }; 100 } // namespace dynamic_fusion 101 } // namespace experimental 102 } // namespace arm_compute 103 #endif /* ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUDEPTHWISECONV2D */ 104