blob: 76decfd6cfe4d7052d8e7a1dd90eb3f166a9d250 [file] [log] [blame]
SiCong Lif44bbc52022-08-29 18:25:51 +01001/*
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#ifndef ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUCONV2D
25#define ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUCONV2D
26
27#include "arm_compute/core/Error.h"
28#include "arm_compute/dynamic_fusion/sketch/OperatorAttributes.h"
29
30namespace arm_compute
31{
32namespace experimental
33{
34namespace dynamic_fusion
35{
36/** Forward declaration */
SiCong Li81fdadd2022-11-23 09:58:18 +000037class GpuWorkloadContext;
SiCong Lif44bbc52022-08-29 18:25:51 +010038class GpuWorkloadSketch;
39
40/** Operator interface. */
41class GpuConv2d final
42{
43public:
44 /** Attributes are a set of backend-agnostic parameters that define what an operator does */
45 using Attributes = Conv2dAttributes;
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 |wei |bia |dst |
52 * |:--------------|:--------------|:--------------|:--------------|
53 * |F16 |F16 |F16 |F16 |
54 * |F32 |F32 |F32 |F32 |
55 *
56 * Valid data layouts:
57 * - NHWC
58 *
59 * @param[in,out] sketch Workload sketch into which the operator will be fused
60 * @param[in] src Source tensor
61 * @param[in] wei Weight tensor
62 * @param[in] bia (Optional) Bias tensor
SiCong Li81fdadd2022-11-23 09:58:18 +000063 * @param[out] dst Destination tensor. If an uninitialized ITensorInfo is passed in, it will be auto-initialized
SiCong Lif44bbc52022-08-29 18:25:51 +010064 * @param[in] attributes Operator attributes
65 */
66 static void create_op(GpuWorkloadSketch &sketch,
67 ITensorInfo *src,
68 ITensorInfo *wei,
69 ITensorInfo *bia,
70 ITensorInfo *dst,
71 const Attributes &attributes);
SiCong Li81fdadd2022-11-23 09:58:18 +000072 /** Check if the operator configuration is supported, irrespective of fusion
73 * Similar to @ref GpuConv2d::create_op()
74 */
75 static Status is_supported_op(const GpuWorkloadContext &context,
76 const ITensorInfo *src,
77 const ITensorInfo *wei,
78 const ITensorInfo *bia,
79 const ITensorInfo *dst,
80 const Attributes &attributes);
81 /** Check if the operator configuration is supported and if it can be fused into the workload sketch.
SiCong Lif44bbc52022-08-29 18:25:51 +010082 * Similar to @ref GpuConv2d::create_op()
83 */
84 static Status validate_op(const GpuWorkloadSketch &sketch,
85 const ITensorInfo *src,
86 const ITensorInfo *wei,
87 const ITensorInfo *bia,
88 const ITensorInfo *dst,
89 const Attributes &attributes);
90};
91} // namespace dynamic_fusion
92} // namespace experimental
93} // namespace arm_compute
94#endif /* ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_OPERATORS_GPUCONV2D */