blob: 2511b0efd591a9e4b4043a325d63d6b53b7a7fb1 [file] [log] [blame]
Viet-Hoa Dob84e2532022-12-13 13:09:10 +00001/*
2 * Copyright (c) 2022 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_GPUOUTPUT
26#define ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUOUTPUT
27
28#include "arm_compute/core/ITensorInfo.h"
29
30namespace arm_compute
31{
32namespace experimental
33{
34namespace dynamic_fusion
35{
36
37/** Forward declaration */
38class GpuWorkloadContext;
39class GpuWorkloadSketch;
40
41/** Operator interface. */
42class GpuOutput final
43{
44public:
45 /** Create an operator and fuse it into the workload sketch.
46 * @note If @ref validate_op() fails, the creation also fails and may throw an error.
47 * @note If @ref validate_op() fails, @p sketch remains unchanged and valid.
48 *
49 * Valid data type configurations:
50 * - Any
51 *
52 * Valid data layouts:
53 * - Any
54 *
55 * @param[in, out] sketch Workload sketch into which the operator will be fused.
56 * @param[in, out] src Source tensor info.
57 * @param[in, out] dst Destination tensor info.
58 * If an uninitialized ITensorInfo is passed in, it will be auto-initialized.
59 */
60 static void create_op(GpuWorkloadSketch &sketch,
61 ITensorInfo *src,
62 ITensorInfo *dst);
63
64 /** Check if the operator configuration is supported, irrespective of fusion.
65 *
66 * @param[in] context Workload context within which the operator is running.
67 * @param[in] src Source tensor info.
68 * @param[in] dst Destination tensor info.
69 */
70 static Status is_supported_op(const GpuWorkloadContext &context,
71 const ITensorInfo *src,
72 const ITensorInfo *dst);
73
74 /** Validate the operator and check if the its configuration is supported and if it can be fused into the workload sketch.
75 *
76 * Similar to @ref GpuOutput::create_op().
77 */
78 static Status validate_op(const GpuWorkloadSketch &sketch,
79 const ITensorInfo *src,
80 const ITensorInfo *dst);
81};
82
83} // namespace dynamic_fusion
84} // namespace experimental
85} // namespace arm_compute
86
87#endif /* ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUOUTPUT */