blob: a4395a62199047f67c1ff806b5fcc8d4f4b11a38 [file] [log] [blame]
Ramy Elgammal404462a2022-11-08 02:14:46 +00001/*
Gunes Bayir0ee13af2024-02-07 15:34:45 +00002 * Copyright (c) 2022-2024 Arm Limited.
Ramy Elgammal404462a2022-11-08 02:14:46 +00003 *
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 Bayir0ee13af2024-02-07 15:34:45 +000024#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY_H
25#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY_H
Ramy Elgammal404462a2022-11-08 02:14:46 +000026
Ramy Elgammal404462a2022-11-08 02:14:46 +000027#include "src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h"
28#include "src/dynamic_fusion/sketch/gpu/operators/internal/GpuElementwiseBinaryCommon.h"
29
30namespace arm_compute
31{
32/** Forward declaration */
33class ITensorInfo;
34namespace experimental
35{
36namespace dynamic_fusion
37{
38/** Forward declaration */
39template <typename T>
40class ArgumentPack;
41
42/** Forward declaration */
SiCong Li19844f62023-05-16 16:46:34 +010043class GpuCkwElementwiseBinary;
Ramy Elgammal404462a2022-11-08 02:14:46 +000044
45class ClComponentElementwiseBinary final : public IGpuKernelComponent
46{
47public:
48 /** Attributes are a set of backend-agnostic parameters that define what a component does */
49 using Attributes = ElementwiseBinaryCommonAttributes;
50
51public:
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 Thomasmathibalanafd38f02023-09-27 17:46:17 +010081 static Status validate(const ArgumentPack<ITensorInfo> &tensors,
82 const ElementwiseBinaryCommonAttributes &attributes);
Ramy Elgammal404462a2022-11-08 02:14:46 +000083
84 /** Constructor
85 *
86 * Similar to @ref ClComponentElementwiseBinary::validate()
87 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010088 ClComponentElementwiseBinary(ComponentId id,
89 const Properties &properties,
90 const ArgumentPack<ITensorInfo> &tensors,
91 const Attributes &attributes);
Ramy Elgammal404462a2022-11-08 02:14:46 +000092
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 Li23882a92023-06-28 09:49:45 +0100103 /** Get writer for the component */
Gunes Bayir0ee13af2024-02-07 15:34:45 +0000104 const IGpuCkwComponentDriver *ckw_component_driver() const override;
Ramy Elgammal404462a2022-11-08 02:14:46 +0000105 /** Get component type */
106 GpuComponentType type() const override
107 {
108 return GpuComponentType::Simple;
109 }
110
111private:
SiCong Li23882a92023-06-28 09:49:45 +0100112 std::unique_ptr<GpuCkwElementwiseBinary> _component_writer;
Ramy Elgammal404462a2022-11-08 02:14:46 +0000113};
114} // namespace dynamic_fusion
115} // namespace experimental
116} // namespace arm_compute
Gunes Bayir0ee13af2024-02-07 15:34:45 +0000117#endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY_H