blob: e1de92968abf21a7ed1510d48fe942abfe58d837 [file] [log] [blame]
Mohammed Suhail Munshi8609ca02024-02-29 17:00:07 +00001/*
2 * Copyright (c) 2024 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#include "arm_compute/runtime/CL/functions/CLScatter.h"
26
27#include "arm_compute/function_info/ScatterInfo.h"
28#include "arm_compute/runtime/CL/CLTensor.h"
29
30#include "src/gpu/cl/operators/ClScatter.h"
31
32namespace arm_compute
33{
34using OperatorType = opencl::ClScatter;
35
36struct CLScatter::Impl
37{
38 std::unique_ptr<OperatorType> op{nullptr};
39 ITensorPack run_pack{};
40};
41
42CLScatter::CLScatter() : _impl(std::make_unique<Impl>())
43{
44}
45
46CLScatter::~CLScatter() = default;
47
48void CLScatter::configure(const ICLTensor *src,
49 const ICLTensor *updates,
50 const ICLTensor *indices,
51 ICLTensor *output,
52 const ScatterInfo &info)
53{
54 ARM_COMPUTE_UNUSED(info);
55 configure(CLKernelLibrary::get().get_compile_context(), src, updates, indices, output, info);
56}
57
58void CLScatter::configure(const CLCompileContext &compile_context,
59 const ICLTensor *src,
60 const ICLTensor *updates,
61 const ICLTensor *indices,
62 ICLTensor *output,
63 const ScatterInfo &info)
64{
65 ARM_COMPUTE_ERROR_ON_NULLPTR(src, indices, output);
66
67 _impl->op = std::make_unique<OperatorType>();
68 _impl->op->configure(compile_context, src->info(), updates->info(), indices->info(), output->info(), info);
69 _impl->run_pack = {{ACL_SRC_0, src}, {ACL_SRC_1, updates}, {ACL_SRC_2, indices}, {ACL_DST, output}};
70}
71
72Status CLScatter::validate(const ITensorInfo *src,
73 const ITensorInfo *updates,
74 const ITensorInfo *indices,
75 const ITensorInfo *output,
76 const ScatterInfo &info)
77{
78 return OperatorType::validate(src, updates, indices, output, info);
79}
80
81void CLScatter::run()
82{
83 _impl->op->run(_impl->run_pack);
84}
85
86} // namespace arm_compute