Compute Library
 23.11
CpuGemmMatrixAdditionKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-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  */
25 
27 #include "arm_compute/core/Types.h"
29 
31 #include "src/core/CPP/Validate.h"
36 namespace arm_compute
37 {
38 namespace cpu
39 {
40 namespace kernels
41 {
42 namespace
43 {
44 static const std::vector<CpuGemmMatrixAdditionKernel::GemmMatrixAddKernel> available_kernels = {
45  {"neon_fp32_gemm_matrix_add", [](const DataTypeISASelectorData &data) { return (data.dt == DataType::F32); },
47  {"neon_fp16_gemm_matrix_add",
48  [](const DataTypeISASelectorData &data) { return (data.dt == DataType::F16) && data.isa.fp16; },
50 
51 };
52 } // namespace
53 
55 {
58 
59  // Perform validation step
61 
62  _beta = beta;
64  DataTypeISASelectorData{src->data_type(), CPUInfo::get().get_isa()});
66  _func = uk->ukernel;
67  // Configure kernel window
69  ICPPKernel::configure(win);
70 }
71 
73 {
75  ARM_COMPUTE_UNUSED(beta);
76 
79 
80  if (dst->total_size() > 0)
81  {
84  }
85  return Status{};
86 }
87 
89 {
93  ARM_COMPUTE_ERROR_ON(tensors.empty());
94 
97 
98  if (_beta != 0.0f)
99  {
100  (*_func)(src, dst, window, _beta);
101  }
102 }
103 
105 {
106  return "CpuGemmMatrixAdditionKernel";
107 }
108 
109 const std::vector<CpuGemmMatrixAdditionKernel::GemmMatrixAddKernel> &
111 {
112  return available_kernels;
113 }
114 } // namespace kernels
115 } // namespace cpu
116 } // namespace arm_compute
arm_compute::Steps
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
arm_compute::cpu::kernels::CpuGemmMatrixAdditionKernel::name
const char * name() const override
Name of the kernel.
Definition: CpuGemmMatrixAdditionKernel.cpp:104
arm_compute::test::validation::src
SimpleTensor< float > src
Definition: DFT.cpp:155
Helpers.h
arm_compute::calculate_max_window
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
Definition: WindowHelpers.cpp:29
arm_compute::test::validation::dst
auto dst
Definition: DFT.cpp:170
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:1079
arm_compute::cpu::kernels::CpuGemmMatrixAdditionKernel::run_op
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Definition: CpuGemmMatrixAdditionKernel.cpp:88
ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:574
Types.h
arm_compute::cpu::neon_fp16_gemm_matrix_add
void neon_fp16_gemm_matrix_add(const ITensor *src, ITensor *dst, const Window &window, float beta)
arm_compute::CPUInfo::get
static CPUInfo & get()
Access the KernelLibrary singleton.
Definition: CPPTypes.cpp:41
arm_compute::ITensor
Interface for CPU tensor.
Definition: ITensor.h:36
arm_compute::ITensorPack::get_tensor
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Definition: ITensorPack.cpp:63
REGISTER_FP16_NEON
#define REGISTER_FP16_NEON(func_name)
Definition: Registrars.h:48
Registrars.h
ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:677
ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:952
REGISTER_FP32_NEON
#define REGISTER_FP32_NEON(func_name)
Definition: Registrars.h:74
arm_compute::ITensorPack::empty
bool empty() const
Checks if pack is empty.
Definition: ITensorPack.cpp:79
ARM_COMPUTE_ERROR_ON_NULLPTR
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
ARM_COMPUTE_ERROR_ON
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
arm_compute::ITensorPack::get_const_tensor
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
Definition: ITensorPack.cpp:53
list.h
ARM_COMPUTE_ERROR_THROW_ON
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
arm_compute::ITensorPack
Tensor packing service.
Definition: ITensorPack.h:39
arm_compute::cpu::kernels::CpuGemmMatrixAdditionKernel::validate
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, float beta)
Static function to check if given info will lead to a valid configuration of CpuGemmMatrixAdditionKer...
Definition: CpuGemmMatrixAdditionKernel.cpp:72
arm_compute::ACL_DST
@ ACL_DST
Definition: Types.h:55
ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
Definition: Validate.h:117
arm_compute::Status
Status class.
Definition: Error.h:52
WindowHelpers.h
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:203
arm_compute::cpu::kernels::CpuGemmMatrixAdditionKernel::configure
void configure(const ITensorInfo *src, ITensorInfo *dst, float beta)
Initialise the kernel's input and output.
Definition: CpuGemmMatrixAdditionKernel.cpp:54
ARM_COMPUTE_UNUSED
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:151
arm_compute::cpu::ICpuKernel< CpuGemmMatrixAdditionKernel >::get_implementation
static const auto * get_implementation(const SelectorType &selector, KernelSelectionType selection_type=KernelSelectionType::Supported)
Micro-kernel selector.
Definition: ICpuKernel.h:54
CpuGemmMatrixAdditionKernel.h
AutoConfiguration.h
arm_compute::IKernel::window
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
arm_compute::ThreadInfo
Information about executing thread and CPU.
Definition: CPPTypes.h:180
arm_compute::Window
Describe a multidimensional execution window.
Definition: Window.h:39
Validate.h
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
arm_compute::DataType::F16
@ F16
16-bit floating-point number
arm_compute::cpu::kernels::DataTypeISASelectorData
Definition: CpuKernelSelectionTypes.h:38
arm_compute::cpu::neon_fp32_gemm_matrix_add
void neon_fp32_gemm_matrix_add(const ITensor *src, ITensor *dst, const Window &window, float beta)
Definition: fp32.cpp:31
ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
arm_compute::ACL_SRC
@ ACL_SRC
Definition: Types.h:44
arm_compute::ITensorInfo
Store the tensor's metadata.
Definition: ITensorInfo.h:44
arm_compute::DataType::F32
@ F32
32-bit floating-point number
arm_compute::test::validation::info
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Validate.h
NEFixedPoint.h
arm_compute::cpu::kernels::CpuGemmMatrixAdditionKernel::get_available_kernels
static const std::vector< GemmMatrixAddKernel > & get_available_kernels()
Definition: CpuGemmMatrixAdditionKernel.cpp:110