blob: e96251196aedd044a6715da17f68c468ba97d5c1 [file] [log] [blame]
Jakub Sujak32741722022-11-25 16:43:18 +00001/*
Gunes Bayircc287732023-01-19 15:56:00 +00002 * Copyright (c) 2022-2023 Arm Limited.
Jakub Sujak32741722022-11-25 16:43:18 +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 */
24#ifndef ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUCLAMP
25#define ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUCLAMP
26
27#include "arm_compute/dynamic_fusion/sketch/attributes/ClampAttributes.h"
28
29namespace arm_compute
30{
31namespace experimental
32{
33namespace dynamic_fusion
34{
35/** Forward declaration */
36class GpuWorkloadContext;
37class GpuWorkloadSketch;
38
39/** Operator interface. */
40class GpuClamp final
41{
42public:
43 /** Attributes are a set of backend-agnostic parameters that define what an operator does */
44 using Attributes = ClampAttributes;
45
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 * |src |dst |
52 * |:--------------|:--------------|
53 * |F16 |F16 |
54 * |F32 |F32 |
55 *
56 * Valid data layouts:
57 * - All
58 *
59 * @param[in, out] sketch Workload sketch into which the operator will be fused
60 * @param[in] src Source tensor info. Data types supported: F16/F32.
Jakub Sujak32741722022-11-25 16:43:18 +000061 * @param[in] attributes Operator attributes
Gunes Bayircc287732023-01-19 15:56:00 +000062 *
63 * @return Pointer for the destination tensor info
Jakub Sujak32741722022-11-25 16:43:18 +000064 */
Gunes Bayircc287732023-01-19 15:56:00 +000065 static ITensorInfo *create_op(GpuWorkloadSketch &sketch,
66 ITensorInfo *src,
67 const Attributes &attributes);
Jakub Sujak32741722022-11-25 16:43:18 +000068
69 /** Check if the operator configuration is supported, irrespective of fusion
70 *
71 * @param[in] context Workload context within which the operator is running
72 * @param[in] src Source tensor info. Data types supported: F16/F32.
Jakub Sujak32741722022-11-25 16:43:18 +000073 * @param[in] attributes Operator attributes
Gunes Bayircc287732023-01-19 15:56:00 +000074 *
75 * @return Status
Jakub Sujak32741722022-11-25 16:43:18 +000076 */
77 static Status is_supported_op(const GpuWorkloadContext &context,
78 const ITensorInfo *src,
Jakub Sujak32741722022-11-25 16:43:18 +000079 const Attributes &attributes);
80
81 /** Validate the operator and check if it can be fused into the workload sketch.
Gunes Bayircc287732023-01-19 15:56:00 +000082 *
83 * Parameters are similar to @ref GpuClamp::create_op()
84 *
85 * @return Status
Jakub Sujak32741722022-11-25 16:43:18 +000086 */
87 static Status validate_op(const GpuWorkloadSketch &sketch,
88 const ITensorInfo *src,
Jakub Sujak32741722022-11-25 16:43:18 +000089 const Attributes &attributes);
90};
91} // namespace dynamic_fusion
92} // namespace experimental
93} // namespace arm_compute
94#endif //ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUCLAMP