blob: 29d30003c3f37f364245d52c630ee0ac5c72bccf [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 */
24#if defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION)
25
26#ifndef ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
27#define ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
28
29#include "src/core/experimental/dynamic_fusion/ClKernelBuildingAPI.h"
30
31#include "src/gpu/cl/ClCompileContext.h"
32#include "src/gpu/cl/IClKernel.h"
33
34namespace arm_compute
35{
36namespace experimental
37{
38namespace dynamic_fusion
39{
40struct TensorBinding
41{
42 TensorBinding(const std::map<ArgumentID, ICLTensor *> binding)
43 : _binding{ binding }
44 {
45 }
46 std::map<ArgumentID, ICLTensor *> _binding;
47};
48class ClCompositeKernel : public opencl::IClKernel
49{
50public:
51 void configure(const opencl::ClCompileContext &, const ClKernelCode &);
52
53 /** Run the composite kernel
54 *
55 * @param tensors TensorBinding object containing run-time tensors information
56 * @param window Execution window
57 * @param queue OpenCL Command queue
58 * @param exec_desc Descriptor containing execution information
59 */
60 virtual void run_composite_op(TensorBinding &tensors, const Window &window, cl::CommandQueue &queue, const ClExecutionDescriptor &exec_desc) override;
61
62private:
63 inline void add_tensor_argument(unsigned int &idx, const ClKernelArgRuntimeDescriptor &arg, ICLTensor *tensor, const Window &arg_slice);
64
65private:
66 ClKernelArgList _arguments{}; /** All kernel arguments required by runtime */
67};
68
69/** Argument Binding.
70 * Tensor Arguments to ICLKernel run_op method need to be passed via an ITensorPack. So the bind_arguments is essentially a converter from TensorBinding to ITensorPack
71 */
72Status bind_arguments(ITensorPack &tensor_pack, const ClKernelCode &, const TensorBinding &);
73
74} // namespace dynamic_fusion
75} // namespace experimental
76} // namespace arm_compute
77#endif // ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
78
79#endif // defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION)