Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 1 | /* |
Gunes Bayir | 0ee13af | 2024-02-07 15:34:45 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2022-2024 Arm Limited. |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 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 | */ |
Gunes Bayir | 0ee13af | 2024-02-07 15:34:45 +0000 | [diff] [blame^] | 24 | #ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY_H |
| 25 | #define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY_H |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 26 | |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 27 | #include "src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h" |
| 28 | #include "src/dynamic_fusion/sketch/gpu/operators/internal/GpuElementwiseBinaryCommon.h" |
| 29 | |
| 30 | namespace arm_compute |
| 31 | { |
| 32 | /** Forward declaration */ |
| 33 | class ITensorInfo; |
| 34 | namespace experimental |
| 35 | { |
| 36 | namespace dynamic_fusion |
| 37 | { |
| 38 | /** Forward declaration */ |
| 39 | template <typename T> |
| 40 | class ArgumentPack; |
| 41 | |
| 42 | /** Forward declaration */ |
SiCong Li | 19844f6 | 2023-05-16 16:46:34 +0100 | [diff] [blame] | 43 | class GpuCkwElementwiseBinary; |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 44 | |
| 45 | class ClComponentElementwiseBinary final : public IGpuKernelComponent |
| 46 | { |
| 47 | public: |
| 48 | /** Attributes are a set of backend-agnostic parameters that define what a component does */ |
| 49 | using Attributes = ElementwiseBinaryCommonAttributes; |
| 50 | |
| 51 | public: |
| 52 | /** Validate the component |
| 53 | * |
| 54 | * @param[in,out] tensors Tensor arguments to the component |
| 55 | * @param[in] attributes Component attributes |
| 56 | * |
| 57 | * @return Status Validation results |
| 58 | * |
| 59 | * Tensor argument names: |
| 60 | * - ACL_SRC_0: lhs |
| 61 | * - ACL_SRC_1: rhs |
| 62 | * - ACL_DST_0: dst |
| 63 | * |
| 64 | * Tensor argument constness: |
| 65 | * - ACL_SRC_0: Const |
| 66 | * - ACL_SRC_1: Const |
| 67 | * - ACL_DST_0: Const |
| 68 | * |
| 69 | * Valid data layouts: |
| 70 | * - All |
| 71 | * |
| 72 | * Valid data type configurations (for DIV FP32/FP16/S32 supported, for POWER only FP32/FP16 supported): |
| 73 | * |ACL_SRC_0 |ACL_SRC_1 |ACL_DST_0 | |
| 74 | * |:--------------|:--------------|:--------------| |
| 75 | * |F16 |F16 |F16 | |
| 76 | * |F32 |F32 |F32 | |
| 77 | * |S32 |S32 |S32 | |
| 78 | * |S16 |S16 |S16 | |
| 79 | * |U8 |U8 |U8 | |
| 80 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 81 | static Status validate(const ArgumentPack<ITensorInfo> &tensors, |
| 82 | const ElementwiseBinaryCommonAttributes &attributes); |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 83 | |
| 84 | /** Constructor |
| 85 | * |
| 86 | * Similar to @ref ClComponentElementwiseBinary::validate() |
| 87 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 88 | ClComponentElementwiseBinary(ComponentId id, |
| 89 | const Properties &properties, |
| 90 | const ArgumentPack<ITensorInfo> &tensors, |
| 91 | const Attributes &attributes); |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 92 | |
| 93 | /** Destructor */ |
| 94 | ~ClComponentElementwiseBinary() override; |
| 95 | /** Prevent instances of this class from being copy constructed */ |
| 96 | ClComponentElementwiseBinary(const ClComponentElementwiseBinary &component) = delete; |
| 97 | /** Prevent instances of this class from being copied */ |
| 98 | ClComponentElementwiseBinary &operator=(const ClComponentElementwiseBinary &component) = delete; |
| 99 | /** Allow instances of this class to be move constructed */ |
| 100 | ClComponentElementwiseBinary(ClComponentElementwiseBinary &&component) = default; |
| 101 | /** Allow instances of this class to be moved */ |
| 102 | ClComponentElementwiseBinary &operator=(ClComponentElementwiseBinary &&component) = default; |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 103 | /** Get writer for the component */ |
Gunes Bayir | 0ee13af | 2024-02-07 15:34:45 +0000 | [diff] [blame^] | 104 | const IGpuCkwComponentDriver *ckw_component_driver() const override; |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 105 | /** Get component type */ |
| 106 | GpuComponentType type() const override |
| 107 | { |
| 108 | return GpuComponentType::Simple; |
| 109 | } |
| 110 | |
| 111 | private: |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 112 | std::unique_ptr<GpuCkwElementwiseBinary> _component_writer; |
Ramy Elgammal | 404462a | 2022-11-08 02:14:46 +0000 | [diff] [blame] | 113 | }; |
| 114 | } // namespace dynamic_fusion |
| 115 | } // namespace experimental |
| 116 | } // namespace arm_compute |
Gunes Bayir | 0ee13af | 2024-02-07 15:34:45 +0000 | [diff] [blame^] | 117 | #endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY_H |