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