blob: 8c44ec5750bcad4d06688db68d358afd302ec33c [file] [log] [blame]
Ramy Elgammalec320d92022-12-14 09:20:09 +00001/*
Gunes Bayir2b9fa592024-01-17 16:07:03 +00002 * Copyright (c) 2023-2024 Arm Limited.
Ramy Elgammalec320d92022-12-14 09:20:09 +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 Bayir2b9fa592024-01-17 16:07:03 +000024#ifndef ACL_ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUSUB_H
25#define ACL_ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUSUB_H
Ramy Elgammalec320d92022-12-14 09:20:09 +000026
27#include "arm_compute/core/Error.h"
28
29namespace arm_compute
30{
31/** Forward declaration */
32class ITensorInfo;
33
34namespace experimental
35{
36namespace dynamic_fusion
37{
38/** Forward declaration */
39class GpuWorkloadContext;
40class GpuWorkloadSketch;
41
42/** Operator interface. */
43class GpuSub final
44{
45public:
46 /** Create an operator and fuse it into the workload sketch.
47 * @note If @ref validate_op() fails, the creation also fails and may throw an error.
48 * @note If @ref validate_op() fails, @p sketch remains unchanged and valid.
49 *
50 * Valid data type configurations:
51 * |lhs |rhs |dst |
52 * |:--------------|:--------------|:-------------|
53 * |F16 |F16 |F16 |
54 * |F32 |F32 |F32 |
Ramy Elgammalec320d92022-12-14 09:20:09 +000055 *
56 * Valid data layouts:
57 * - Any
58 *
59 * @param[in,out] sketch Workload sketch into which the operator will be fused
60 * @param[in] lhs Left hand side tensor info. Data types supported: U8/S16/S32/F16/F32.
61 * @param[in] rhs Right hand side tensor info. Same as @p lhs.
62 *
63 * @return Pointer for the destination tensor info
64 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010065 static ITensorInfo *create_op(GpuWorkloadSketch &sketch, ITensorInfo *lhs, ITensorInfo *rhs);
Ramy Elgammalec320d92022-12-14 09:20:09 +000066
67 /** Check if the operator configuration is supported, irrespective of fusion
68 *
69 * @param[in] context Workload context within which the operator is running
70 * @param[in] lhs Left hand side tensor info. Data types supported: U8/S16/S32/F16/F32.
71 * @param[in] rhs Right hand side tensor info. Same as @p lhs.
72 *
73 * @return Status
74 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010075 static Status is_supported_op(const GpuWorkloadContext &context, const ITensorInfo *lhs, const ITensorInfo *rhs);
Ramy Elgammalec320d92022-12-14 09:20:09 +000076
77 /** Validate the operator and check if its configuration is supported and if it can be fused into the workload sketch.
78 *
79 * Parameters are similar to @ref GpuSub::create_op()
80 *
81 * @return Status
82 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010083 static Status validate_op(const GpuWorkloadSketch &sketch, const ITensorInfo *rhs, const ITensorInfo *lhs);
Ramy Elgammalec320d92022-12-14 09:20:09 +000084};
85} // namespace dynamic_fusion
86} // namespace experimental
87} // namespace arm_compute
Gunes Bayir2b9fa592024-01-17 16:07:03 +000088#endif // ACL_ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUSUB_H