blob: ae5a01f6796d95adc0161e54ae0f267327b2b7a6 [file] [log] [blame]
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +00001/*
2 * Copyright (c) 2023 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/runtime/CL/functions/CLMatMul.h"
25#include "arm_compute/runtime/CL/CLTensor.h"
26#include "arm_compute/runtime/CL/CLTypes.h"
27#include "src/gpu/cl/operators/ClMatMul.h"
28
29namespace arm_compute
30{
31using OperatorType = opencl::ClMatMul;
32
33struct CLMatMul::Impl
34{
35 std::unique_ptr<OperatorType> op{ nullptr };
36 ITensorPack run_pack{};
37};
38CLMatMul::CLMatMul()
39 : _impl(std::make_unique<Impl>())
40{
41}
42
43CLMatMul::~CLMatMul() = default;
44
Mohammed Suhail Munshia1b1e412023-03-23 22:21:31 +000045void CLMatMul::configure(ICLTensor *lhs, ICLTensor *rhs, ICLTensor *output, const MatMulInfo &matmul_info, const GpuMatMulSettings &settings)
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000046{
Mohammed Suhail Munshia1b1e412023-03-23 22:21:31 +000047 ARM_COMPUTE_UNUSED(settings);
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000048 configure(CLKernelLibrary::get().get_compile_context(), lhs, rhs, output, matmul_info);
49}
50
Mohammed Suhail Munshia1b1e412023-03-23 22:21:31 +000051void CLMatMul::configure(const CLCompileContext &compile_context, ICLTensor *lhs, ICLTensor *rhs, ICLTensor *output, const MatMulInfo &matmul_info, const GpuMatMulSettings &settings)
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000052{
53 ARM_COMPUTE_ERROR_ON_NULLPTR(lhs, rhs, output);
Mohammed Suhail Munshia1b1e412023-03-23 22:21:31 +000054 ARM_COMPUTE_UNUSED(settings);
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000055
56 _impl->op = std::make_unique<OperatorType>();
57 _impl->op->configure(compile_context, lhs->info(), rhs->info(), output->info(), matmul_info);
58 _impl->run_pack = { { ACL_SRC_0, lhs }, { ACL_SRC_1, rhs }, { ACL_DST, output } };
59}
60
61Status CLMatMul::validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *output, const MatMulInfo &matmul_info)
62{
63 return OperatorType::validate(lhs, rhs, output, matmul_info);
64}
65
66void CLMatMul::run()
67{
68 _impl->op->run(_impl->run_pack);
69}
70
71} // namespace arm_compute