blob: 46033d842bf9f5c06561522a37989534dae38de5 [file] [log] [blame]
Ramy Elgammal404462a2022-11-08 02:14:46 +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#include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuAdd.h"
25
26#include "src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h"
27#include "src/dynamic_fusion/sketch/gpu/operators/internal/GpuElementwiseBinaryCommon.h"
28
29#include "src/common/utils/Log.h"
30
31namespace arm_compute
32{
33namespace experimental
34{
35namespace dynamic_fusion
36{
37Status GpuAdd::validate_op(const GpuWorkloadSketch &sketch,
38 const ITensorInfo *lhs,
39 const ITensorInfo *rhs,
40 const ITensorInfo *dst)
41{
42 ElementwiseBinaryCommonAttributes common_attributes{};
43 common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::ADD);
44 return GpuElementwiseBinaryCommon::validate_op(sketch, lhs, rhs, dst, common_attributes);
45}
46
47Status GpuAdd::is_supported_op(const GpuWorkloadContext &context,
48 const ITensorInfo *lhs,
49 const ITensorInfo *rhs,
50 const ITensorInfo *dst)
51{
52 ElementwiseBinaryCommonAttributes common_attributes{};
53 common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::ADD);
54 return GpuElementwiseBinaryCommon::is_supported_op(context, lhs, rhs, dst, common_attributes);
55}
56
57void GpuAdd::create_op(GpuWorkloadSketch &sketch,
58 ITensorInfo *lhs,
59 ITensorInfo *rhs,
60 ITensorInfo *dst)
61{
62 // Assert validation
63 ARM_COMPUTE_ERROR_THROW_ON(GpuAdd::validate_op(sketch, lhs, rhs, dst));
64 ARM_COMPUTE_LOG_PARAMS(lhs, rhs, dst);
65
66 // Set the elementwise operation to ADD then call the elementwise common create_op
67 ElementwiseBinaryCommonAttributes common_attributes{};
68 common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::ADD);
69 GpuElementwiseBinaryCommon::create_op(sketch, lhs, rhs, dst, common_attributes);
70}
71
72} // namespace dynamic_fusion
73} // namespace experimental
74} // namespace arm_compute