blob: bf70d6a22642566d4278dce76e40bffbf170f146 [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 Lib63b1192022-01-28 18:24:39 +000024#ifndef ENABLE_EXPERIMENTAL_DYNAMIC_FUSION
25#error "This experimental feature must be enabled with -DENABLE_EXPERIMENTAL_DYNAMIC_FUSION"
26#endif /* ENABLE_EXPERIMENTAL_DYNAMIC_FUSION */
Giorgio Arena232c4522022-03-03 10:09:01 +000027
28#ifndef ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
29#define ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
30
SiCong Lib63b1192022-01-28 18:24:39 +000031#include "arm_compute/core/experimental/ClWorkload.h"
Giorgio Arena232c4522022-03-03 10:09:01 +000032#include "src/gpu/cl/ClCompileContext.h"
33#include "src/gpu/cl/IClKernel.h"
34
35namespace arm_compute
36{
37namespace experimental
38{
39namespace dynamic_fusion
40{
SiCong Lib63b1192022-01-28 18:24:39 +000041struct ClExecutionDescriptor;
42struct ClKernelCode;
43
44class ClCompositeKernel final : public opencl::IClKernel
Giorgio Arena232c4522022-03-03 10:09:01 +000045{
46public:
47 void configure(const opencl::ClCompileContext &, const ClKernelCode &);
48
49 /** Run the composite kernel
SiCong Lib63b1192022-01-28 18:24:39 +000050 * @note The slots / keys in ITensorPack are the argument Ids of the tensors in blueprint
Giorgio Arena232c4522022-03-03 10:09:01 +000051 *
SiCong Lib63b1192022-01-28 18:24:39 +000052 * @param tensors ITensorPack object containing run-time tensor memories
Giorgio Arena232c4522022-03-03 10:09:01 +000053 * @param window Execution window
54 * @param queue OpenCL Command queue
55 * @param exec_desc Descriptor containing execution information
56 */
SiCong Lib63b1192022-01-28 18:24:39 +000057 virtual void run_composite_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue, const ClExecutionDescriptor &exec_desc) override;
Giorgio Arena232c4522022-03-03 10:09:01 +000058
59private:
SiCong Lib63b1192022-01-28 18:24:39 +000060 /** Set a kernel tensor argument
61 *
62 * @param[in,out] idx Index at which to start adding the tensor's arguments. Will be incremented by the number of kernel arguments set.
63 * @param[in] arg Kernel argument descriptor accompanying @p tensor
64 * @param[in] tensor Tensor to set as an argument of the object's kernel.
65 * @param[in] arg_slice Window the kernel will be run on.
66 * @param[out] cl_images Extra cl images created from the tensor (will need to be retained until the kernel is enqueued)
67 */
68 inline void add_tensor_argument(unsigned int &idx, const ClKernelArgDescriptor &arg, const ICLTensor *tensor, const Window &arg_slice, std::vector<cl::Image2D> &cl_images);
Giorgio Arena232c4522022-03-03 10:09:01 +000069
70private:
71 ClKernelArgList _arguments{}; /** All kernel arguments required by runtime */
72};
73
Giorgio Arena232c4522022-03-03 10:09:01 +000074} // namespace dynamic_fusion
75} // namespace experimental
76} // namespace arm_compute
SiCong Lib63b1192022-01-28 18:24:39 +000077#endif // ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H