Compute Library
 22.08
ClCompositeKernel.h
Go to the documentation of this file.
1 /*
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 #ifdef ENABLE_EXPERIMENTAL_DYNAMIC_FUSION
25 
26 #ifndef ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
27 #define ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
28 
31 #include "src/gpu/cl/IClKernel.h"
32 
33 namespace arm_compute
34 {
35 namespace experimental
36 {
37 namespace dynamic_fusion
38 {
39 struct ClExecutionDescriptor;
40 struct ClKernelCode;
41 
43 {
44 public:
45  void configure(const opencl::ClCompileContext &, const ClKernelCode &);
46 
47  /** Run the composite kernel
48  * @note The slots / keys in ITensorPack are the argument Ids of the tensors in blueprint
49  *
50  * @param tensors ITensorPack object containing run-time tensor memories
51  * @param window Execution window
52  * @param queue OpenCL Command queue
53  * @param exec_desc Descriptor containing execution information
54  */
55  virtual void run_composite_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue, const ClExecutionDescriptor &exec_desc) override;
56 
57 private:
58  /** Set a kernel tensor argument
59  *
60  * @param[in,out] idx Index at which to start adding the tensor's arguments. Will be incremented by the number of kernel arguments set.
61  * @param[in] arg Kernel argument descriptor accompanying @p tensor
62  * @param[in] tensor Tensor to set as an argument of the object's kernel.
63  * @param[in] arg_slice Window the kernel will be run on.
64  * @param[out] cl_images Extra cl images created from the tensor (will need to be retained until the kernel is enqueued)
65  */
66  inline void add_tensor_argument(unsigned int &idx, const ClKernelArgDescriptor &arg, const ICLTensor *tensor, const Window &arg_slice, std::vector<cl::Image2D> &cl_images);
67 
68 private:
69  ClKernelArgList _arguments{}; /** All kernel arguments required by runtime */
70 };
71 
72 } // namespace dynamic_fusion
73 } // namespace experimental
74 } // namespace arm_compute
75 #endif // ARM_COMPUTE_EXPERIMENTAL_DYNAMICFUSION_CLCOMPOSITEKERNEL_H
76 #endif /* ENABLE_EXPERIMENTAL_DYNAMIC_FUSION */
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void configure(const opencl::ClCompileContext &, const ClKernelCode &)
Common interface for all the OpenCL kernels.
Definition: ICLKernel.h:81
Copyright (c) 2017-2022 Arm Limited.
std::map< int, ClKernelArgDescriptor > ClKernelArgList
Definition: ClWorkload.h:87
Describes all the info required to add a kernel argument at run time.
Definition: ClWorkload.h:70
Contains kernel code to be compiled and run in a ClUnitWorkload.
Definition: ClWorkload.h:100
Descriptor containing information required to run a single ClWorkload.
Definition: ClWorkload.h:91
CLCompileContext class.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
virtual void run_composite_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue, const ClExecutionDescriptor &exec_desc) override
Run the composite kernel.
Tensor packing service.
Definition: ITensorPack.h:39
Describe a multidimensional execution window.
Definition: Window.h:39