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 #ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_GPULOGICALKERNEL 25 #define SRC_DYNAMIC_FUSION_SKETCH_GPU_GPULOGICALKERNEL 26 27 #include "src/dynamic_fusion/sketch/gpu/GpuKernelComponentGroup.h" 28 #include "src/dynamic_fusion/sketch/gpu/GpuKernelSourceCode.h" 29 30 #include <memory> 31 #include <vector> 32 33 namespace arm_compute 34 { 35 namespace experimental 36 { 37 namespace dynamic_fusion 38 { 39 /** Forward declaration */ 40 class GpuComponentServices; 41 class IGpuKernelComponent; 42 43 /** A wrapper-processor of a @ref GpuKernelComponentGroup 44 * It adds the load (if any) and store components to the component group 45 * The @ref GpuLogicalKernel represents a complete kernel, and can proceed to invoke any kernel writer to generate the full kernel code 46 */ 47 class GpuLogicalKernel 48 { 49 public: 50 /** Constructor 51 * 52 * @param[in] services @ref GpuComponentServices to be used 53 * @param[in] components Component group from which this logical kernel is initialized 54 */ 55 explicit GpuLogicalKernel(GpuComponentServices *services, const GpuKernelComponentGroup &components); 56 /** Allow instances of this class to be copy constructed */ 57 GpuLogicalKernel(const GpuLogicalKernel &) = default; 58 /** Allow instances of this class to be copied */ 59 GpuLogicalKernel &operator=(const GpuLogicalKernel &) = default; 60 /** Allow instances of this class to be move constructed */ 61 GpuLogicalKernel(GpuLogicalKernel &&) = default; 62 /** Allow instances of this class to be moved */ 63 GpuLogicalKernel &operator=(GpuLogicalKernel &&) = default; 64 /** Generate a @ref GpuKernelSourceCode */ 65 GpuKernelSourceCode write_kernel_code(); 66 67 private: 68 GpuKernelComponentGroup _comp_group{}; 69 std::vector<std::unique_ptr<IGpuKernelComponent>> _store_components{}; 70 }; 71 } // namespace dynamic_fusion 72 } // namespace experimental 73 } // namespace arm_compute 74 #endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_GPULOGICALKERNEL */ 75