xref: /aosp_15_r20/external/ComputeLibrary/src/cpu/kernels/CpuKernelSelectionTypes.h (revision c217d954acce2dbc11938adb493fc0abd69584f3)
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_CPU_KERNEL_SELECTION_TYPES_H
25 #define ARM_COMPUTE_CPU_KERNEL_SELECTION_TYPES_H
26 
27 #include "arm_compute/core/Types.h"
28 #include "src/common/cpuinfo/CpuIsaInfo.h"
29 
30 namespace arm_compute
31 {
32 namespace cpu
33 {
34 namespace kernels
35 {
36 // Selector data types
37 struct DataTypeISASelectorData
38 {
39     DataType            dt;
40     cpuinfo::CpuIsaInfo isa;
41 };
42 
43 struct DataTypeDataLayoutISASelectorData
44 {
45     DataType                   dt;
46     DataLayout                 dl;
47     const cpuinfo::CpuIsaInfo &isa;
48 };
49 
50 struct CastDataTypeISASelectorData
51 {
52     DataType                   src_dt;
53     DataType                   dst_dt;
54     const cpuinfo::CpuIsaInfo &isa;
55 };
56 
57 struct PoolDataTypeISASelectorData
58 {
59     DataType            dt;
60     DataLayout          dl;
61     int                 pool_stride_x;
62     Size2D              pool_size;
63     cpuinfo::CpuIsaInfo isa;
64 };
65 
66 struct ElementwiseDataTypeISASelectorData
67 {
68     DataType            dt;
69     cpuinfo::CpuIsaInfo isa;
70     int                 op;
71 };
72 struct DepthwiseConv2dNativeDataTypeISASelectorData
73 {
74     DataType                   weights_dt;
75     DataType                   source_dt;
76     const cpuinfo::CpuIsaInfo &isa;
77 };
78 
79 struct ActivationDataTypeISASelectorData
80 {
81     DataType                                dt;
82     const CPUModel                         &cpumodel;
83     const cpuinfo::CpuIsaInfo              &isa;
84     ActivationLayerInfo::ActivationFunction f;
85 };
86 
87 struct CpuAddKernelDataTypeISASelectorData
88 {
89     DataType            dt;
90     cpuinfo::CpuIsaInfo isa;
91     bool                can_use_fixedpoint;
92 };
93 
94 struct ScaleKernelDataTypeISASelectorData
95 {
96     DataType            dt;
97     cpuinfo::CpuIsaInfo isa;
98     InterpolationPolicy interpolation_policy;
99 };
100 
101 // Selector pointer types
102 using DataTypeISASelectorPtr                      = std::add_pointer<bool(const DataTypeISASelectorData &data)>::type;
103 using DataTypeDataLayoutSelectorPtr               = std::add_pointer<bool(const DataTypeDataLayoutISASelectorData &data)>::type;
104 using PoolDataTypeISASelectorPtr                  = std::add_pointer<bool(const PoolDataTypeISASelectorData &data)>::type;
105 using ElementwiseDataTypeISASelectorPtr           = std::add_pointer<bool(const ElementwiseDataTypeISASelectorData &data)>::type;
106 using DepthwiseConv2dNativeDataTypeISASelectorPtr = std::add_pointer<bool(const DepthwiseConv2dNativeDataTypeISASelectorData &data)>::type;
107 using CastDataTypeISASelectorDataPtr              = std::add_pointer<bool(const CastDataTypeISASelectorData &data)>::type;
108 using ActivationDataTypeISASelectorDataPtr        = std::add_pointer<bool(const ActivationDataTypeISASelectorData &data)>::type;
109 using CpuAddKernelDataTypeISASelectorDataPtr      = std::add_pointer<bool(const CpuAddKernelDataTypeISASelectorData &data)>::type;
110 using ScaleKernelDataTypeISASelectorDataPtr       = std::add_pointer<bool(const ScaleKernelDataTypeISASelectorData &data)>::type;
111 
112 } // namespace kernels
113 } // namespace cpu
114 } // namespace arm_compute
115 
116 #endif // ARM_COMPUTE_CPU_KERNEL_SELECTION_TYPES_H
117