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 ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCH 25 #define ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCH 26 27 #include "arm_compute/core/TensorInfo.h" 28 #include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadContext.h" 29 30 #include <memory> 31 32 namespace arm_compute 33 { 34 namespace experimental 35 { 36 namespace dynamic_fusion 37 { 38 /** A descriptor of a workload of operators 39 * 40 * A "workload" is a basic unit of computation to schedule and perform. It contains one or more operators that can be "fused" together. 41 * Note that a workload may still contain multiple kernels. 42 */ 43 class GpuWorkloadSketch 44 { 45 public: 46 /** Global context used for the creation of a workload */ 47 using Context = GpuWorkloadContext; 48 /** Internal opaque implementation */ 49 class Implementation; 50 51 public: 52 /** Constructor 53 * 54 * @param[in] context Gpu context for the creation of a workload 55 */ 56 explicit GpuWorkloadSketch(GpuWorkloadContext *context); 57 /** Destructor */ 58 ~GpuWorkloadSketch(); 59 /** Get the implementation */ 60 Implementation &implementation(); 61 /** Get the implementation */ 62 const Implementation &implementation() const; 63 /** Get the gpu workload context of this sketch */ 64 const GpuWorkloadContext *gpu_context() const; 65 /** Create a @ref TensorInfo associated with the workload sketch. 66 * 67 * @return TensorInfo Newly created tensor info 68 */ 69 template <typename... Args> create_tensor_info(Args &&...args)70 TensorInfo create_tensor_info(Args &&... args) 71 { 72 auto tensor_info = TensorInfo(std::forward<Args>(args)...); 73 register_new_tensor(tensor_info); 74 return tensor_info; 75 } 76 /** Create a default @ref TensorInfo associated with the workload sketch 77 * It is usually used by user input or output tensors 78 * 79 * @return TensorInfo Newly created tensor info 80 */ 81 TensorInfo create_tensor_info(); 82 83 private: 84 /** Register a new tensor by setting a new id to it and register its memory descriptor in the sketch 85 * 86 * @param[in,out] tensor_info @ref ITensorInfo that will be registered 87 */ 88 void register_new_tensor(ITensorInfo &tensor_info); 89 std::unique_ptr<Implementation> _impl; /**< Internal opaque implementation*/ 90 }; 91 92 } // namespace dynamic_fusion 93 } // namespace experimental 94 } // namespace arm_compute 95 #endif /* ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCH */ 96