blob: e8bdad706b011e2a30ec6af7bbc1f9b7fbeb1b21 [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"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010025
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000026#include "arm_compute/runtime/CL/CLTensor.h"
27#include "arm_compute/runtime/CL/CLTypes.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000029#include "src/gpu/cl/operators/ClMatMul.h"
30
31namespace arm_compute
32{
33using OperatorType = opencl::ClMatMul;
34
35struct CLMatMul::Impl
36{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010037 std::unique_ptr<OperatorType> op{nullptr};
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000038 ITensorPack run_pack{};
39};
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010040CLMatMul::CLMatMul() : _impl(std::make_unique<Impl>())
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000041{
42}
43
44CLMatMul::~CLMatMul() = default;
45
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010046void CLMatMul::configure(ICLTensor *lhs,
47 ICLTensor *rhs,
48 ICLTensor *output,
49 const MatMulInfo &matmul_info,
50 const GpuMatMulSettings &settings,
51 const ActivationLayerInfo &act_info)
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000052{
Mohammed Suhail Munshia1b1e412023-03-23 22:21:31 +000053 ARM_COMPUTE_UNUSED(settings);
Mohammed Suhail Munshi94abde42023-05-25 16:48:43 +010054 configure(CLKernelLibrary::get().get_compile_context(), lhs, rhs, output, matmul_info, settings, act_info);
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000055}
56
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010057void CLMatMul::configure(const CLCompileContext &compile_context,
58 ICLTensor *lhs,
59 ICLTensor *rhs,
60 ICLTensor *output,
61 const MatMulInfo &matmul_info,
62 const GpuMatMulSettings &settings,
Mohammed Suhail Munshi94abde42023-05-25 16:48:43 +010063 const ActivationLayerInfo &act_info)
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000064{
65 ARM_COMPUTE_ERROR_ON_NULLPTR(lhs, rhs, output);
Mohammed Suhail Munshia1b1e412023-03-23 22:21:31 +000066 ARM_COMPUTE_UNUSED(settings);
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000067
68 _impl->op = std::make_unique<OperatorType>();
Mohammed Suhail Munshi94abde42023-05-25 16:48:43 +010069 _impl->op->configure(compile_context, lhs->info(), rhs->info(), output->info(), matmul_info, act_info);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010070 _impl->run_pack = {{ACL_SRC_0, lhs}, {ACL_SRC_1, rhs}, {ACL_DST, output}};
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000071}
72
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010073Status CLMatMul::validate(const ITensorInfo *lhs,
74 const ITensorInfo *rhs,
75 const ITensorInfo *output,
76 const MatMulInfo &matmul_info,
77 const ActivationLayerInfo &act_info)
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000078{
Mohammed Suhail Munshi94abde42023-05-25 16:48:43 +010079 return OperatorType::validate(lhs, rhs, output, matmul_info, act_info);
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000080}
81
82void CLMatMul::run()
83{
84 _impl->op->run(_impl->run_pack);
85}
86
87} // namespace arm_compute