blob: 463fc5e7cf7cf1a22019f767ee11183ab54aeda6 [file] [log] [blame]
Giorgio Arena232c4522022-03-03 10:09:01 +00001/*
2 * Copyright (c) 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 */
SiCong Li4e9f5682022-05-10 10:15:59 +010024#ifdef ENABLE_EXPERIMENTAL_DYNAMIC_FUSION
Giorgio Arena232c4522022-03-03 10:09:01 +000025
26#ifndef ARM_COMPUTE_EXPERIMENTAL_CLKERNELBUILDINGAPI_H
27#define ARM_COMPUTE_EXPERIMENTAL_CLKERNELBUILDINGAPI_H
28
29#include "arm_compute/core/CL/CLCompileContext.h"
30#include "arm_compute/core/Window.h"
SiCong Lib63b1192022-01-28 18:24:39 +000031#include "arm_compute/core/experimental/ClWorkload.h"
32#include "arm_compute/core/experimental/DependencyGraph.h"
33#include "src/core/experimental/dynamic_fusion/WorkloadImpl/ClKernelDescriptors.h"
Giorgio Arena232c4522022-03-03 10:09:01 +000034
35namespace arm_compute
36{
37namespace experimental
38{
39namespace dynamic_fusion
40{
SiCong Lib63b1192022-01-28 18:24:39 +000041using ArgumentID = DependencyGraph::Id;
Giorgio Arena232c4522022-03-03 10:09:01 +000042
SiCong Lib63b1192022-01-28 18:24:39 +000043static constexpr ArgumentID g_arg_placeholder = DependencyGraph::empty_id();
Giorgio Arena232c4522022-03-03 10:09:01 +000044
45/** Intermediate representation of the final, complete kernel source. */
46class ClKernelBlueprint
47{
48public:
49 ClKernelBlueprint();
50 ~ClKernelBlueprint();
51
52private:
53 struct Implementation;
54 std::unique_ptr<Implementation> _impl;
55
56public:
57 Implementation &impl();
58 const Implementation &impl() const;
59};
60
61///// Kernel Components /////
Michalis Spyroub1fcefd2022-06-15 19:02:28 +010062/** Component: Eltwise Operator */
63Status add_kcomp_eltwise_op(ClKernelBlueprint &, const ClElementwiseKernelDescriptor &, ArgumentID src0_id,
64 ArgumentID src1_id, ArgumentID &dst_id);
65
66/** Component: Floor */
67Status add_kcomp_floor(ClKernelBlueprint &, const ClFloorKernelDescriptor &, ArgumentID src_id,
68 ArgumentID &dst_id);
Giorgio Arena232c4522022-03-03 10:09:01 +000069
70/** Component: Activation */
SiCong Lib63b1192022-01-28 18:24:39 +000071Status add_kcomp_activation(ClKernelBlueprint &, const ClActivationKernelDescriptor &, ArgumentID src_id, ArgumentID &dst_id);
Giorgio Arena232c4522022-03-03 10:09:01 +000072
Gunes Bayir16c56972022-03-28 21:32:33 +010073/** Component: Direct Convolution **/
SiCong Lib63b1192022-01-28 18:24:39 +000074Status add_kcomp_direct_conv2d(ClKernelBlueprint &, const ClDirectConv2dKernelDescriptor &,
75 ArgumentID src_id, ArgumentID weight_id, ArgumentID bias_id, ArgumentID &dst_id);
Gunes Bayir16c56972022-03-28 21:32:33 +010076
SiCong Lib63b1192022-01-28 18:24:39 +000077Status add_kcomp_store(ClKernelBlueprint &, const StoreType &store_type, ArgumentID src_id, ArgumentID dst_id);
Giorgio Arena232c4522022-03-03 10:09:01 +000078
SiCong Lib63b1192022-01-28 18:24:39 +000079Status add_tensor(ClKernelBlueprint &, ITensorInfo *, ArgumentID &, ArgumentID merge_point = DependencyGraph::empty_id());
Giorgio Arena232c4522022-03-03 10:09:01 +000080
81///// Kernel Components /////
82
83///// Building /////
84
SiCong Lib63b1192022-01-28 18:24:39 +000085/** Update existing merge tensor @p merge_point to point to @p t_id
86 *
87 * @param t_id
88 * @param merge_point
89 * @return Status
90 */
91Status update_merge_point(ClKernelBlueprint &, ArgumentID t_id, ArgumentID merge_point);
Giorgio Arena232c4522022-03-03 10:09:01 +000092
SiCong Lib63b1192022-01-28 18:24:39 +000093/** Get dependency graph
94 *
95 * @return DependencyGraph
96 */
97DependencyGraph get_dependency_graph(const ClKernelBlueprint &blueprint);
Giorgio Arena232c4522022-03-03 10:09:01 +000098
99/** All information required for building the @ref ClKernelCode */
100struct ClCodeBuilderContext
101{
102 GpuInfo gpu_info{};
103};
104
105Status set_tile_info(ClKernelBlueprint &, const TileDescriptor &);
106
107/** Build final kernel source from KernelBlueprint */
108Status build(ClKernelCode &code, const ClCodeBuilderContext &, ClKernelBlueprint &);
109
110///// Building /////
111
112///// Tuning /////
Giorgio Arena232c4522022-03-03 10:09:01 +0000113
114Status tune_static(ClExecutionDescriptor &, const ClKernelCode &);
115
116///// Tuning /////
117
118} // namespace dynamic_fusion
119} // namespace experimental
120} // namespace arm_compute
SiCong Li4e9f5682022-05-10 10:15:59 +0100121#endif //ARM_COMPUTE_EXPERIMENTAL_CLKERNELBUILDINGAPI_H
122#endif /* ENABLE_EXPERIMENTAL_DYNAMIC_FUSION */