24.02.1
ICpuKernel.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2021-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
#ifndef ARM_COMPUTE_ICPUKERNEL_H
25
#define ARM_COMPUTE_ICPUKERNEL_H
26
27
#include "
arm_compute/core/CPP/ICPPKernel.h
"
28
29
#include "
src/cpu/kernels/CpuKernelSelectionTypes.h
"
30
31
namespace
arm_compute
32
{
33
namespace
cpu
34
{
35
enum class
KernelSelectionType
36
{
37
Preferred
,
/**< Retrieve the best implementation available for the given Cpu ISA, ignoring the build flags */
38
Supported
/**< Retrieve the best implementation available for the given Cpu ISA that is supported by the current build */
39
};
40
41
template
<
class
Derived>
42
class
ICpuKernel
:
public
ICPPKernel
43
{
44
public
:
45
/** Micro-kernel selector
46
*
47
* @param[in] selector Selection struct passed including information to help pick the appropriate micro-kernel
48
* @param[in] selection_type (Optional) Decides whether to get the best implementation for the given hardware or for the given build
49
*
50
* @return A matching micro-kernel else nullptr
51
*/
52
53
template
<
typename
SelectorType>
54
static
const
auto
*
get_implementation
(
const
SelectorType &selector,
55
KernelSelectionType
selection_type =
KernelSelectionType::Supported
)
56
{
57
using
kernel_type =
58
typename
std::remove_reference<decltype(Derived::get_available_kernels())>::type::value_type;
59
60
for
(
const
auto
&uk : Derived::get_available_kernels())
61
{
62
if
(uk.is_selected(selector) && (selection_type ==
KernelSelectionType::Preferred
|| uk.ukernel !=
nullptr
))
63
{
64
return
&uk;
65
}
66
}
67
68
return
static_cast<
kernel_type *
>
(
nullptr
);
69
}
70
};
71
}
// namespace cpu
72
}
// namespace arm_compute
73
#endif
/* ARM_COMPUTE_ICPUKERNEL_H */
arm_compute::cpu::KernelSelectionType
KernelSelectionType
Definition:
ICpuKernel.h:35
arm_compute::cpu::KernelSelectionType::Preferred
@ Preferred
Retrieve the best implementation available for the given Cpu ISA, ignoring the build flags.
CpuKernelSelectionTypes.h
arm_compute::ICPPKernel
Common interface for all kernels implemented in C++.
Definition:
ICPPKernel.h:38
arm_compute::cpu::ICpuKernel
Definition:
ICpuKernel.h:42
arm_compute::cpu::KernelSelectionType::Supported
@ Supported
Retrieve the best implementation available for the given Cpu ISA that is supported by the current bui...
arm_compute::cpu::ICpuKernel::get_implementation
static const auto * get_implementation(const SelectorType &selector, KernelSelectionType selection_type=KernelSelectionType::Supported)
Micro-kernel selector.
Definition:
ICpuKernel.h:54
arm_compute
Copyright (c) 2017-2024 Arm Limited.
Definition:
introduction.dox:24
ICPPKernel.h
src
cpu
ICpuKernel.h
Generated on Mon Mar 18 2024 11:32:00 for Compute Library by
1.8.17