Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023 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 | |
| 25 | #ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADCONTEXTIMPL_H |
| 26 | #define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADCONTEXTIMPL_H |
| 27 | |
| 28 | #include "arm_compute/core/CL/CLCompileContext.h" |
| 29 | #include "arm_compute/core/ITensorInfo.h" |
| 30 | #include "arm_compute/dynamic_fusion/sketch/MemoryDescriptor.h" |
| 31 | #include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadContext.h" |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | namespace experimental |
| 36 | { |
| 37 | namespace dynamic_fusion |
| 38 | { |
| 39 | |
| 40 | /** Internal implementation of workload context. */ |
| 41 | class GpuWorkloadContext::Impl |
| 42 | { |
| 43 | public: |
| 44 | /** Constructor |
| 45 | * |
| 46 | * @param[in] gpu_language Target GPU language. |
| 47 | * @param[in] cl_compile_ctx CL compile context. |
| 48 | */ |
| 49 | Impl(GpuLanguage gpu_language, CLCompileContext *cl_compile_ctx); |
| 50 | |
| 51 | /** Copy constructor */ |
| 52 | Impl(Impl &) = default; |
| 53 | |
| 54 | /** Assignment */ |
| 55 | Impl& operator=(Impl &) = default; |
| 56 | |
| 57 | /** Get target GPU language. */ |
| 58 | GpuLanguage gpu_language() const; |
| 59 | |
| 60 | /** Get CL compile context. */ |
| 61 | const CLCompileContext *cl_compile_context() const; |
| 62 | |
| 63 | /** Get memory descriptor registry. */ |
| 64 | const MemoryDescriptorMap &mem_map() const; |
| 65 | |
| 66 | /** Set a new ID and register the user tensor info. |
| 67 | * |
| 68 | * @param[in, out] tensor_info The tensor info to be registered. |
| 69 | */ |
| 70 | void register_user_tensor(ITensorInfo &tensor_info); |
| 71 | |
| 72 | /** Set a new ID and register the auxiliary tensor info. |
| 73 | * |
| 74 | * @param[in, out] tensor_info The tensor info to be registered. |
| 75 | * @param[in] mem_info The auxiliary tensor memory info. |
| 76 | */ |
| 77 | void register_aux_tensor(ITensorInfo &tensor_info, const AuxMemoryInfo &mem_info); |
| 78 | |
| 79 | /** Set a new ID and register the virtual tensor info. |
| 80 | * |
| 81 | * @param[in, out] tensor_info The tensor info to be registered. |
| 82 | */ |
| 83 | void register_virtual_tensor(ITensorInfo &tensor_info); |
| 84 | |
| 85 | private: |
| 86 | ITensorInfo::Id next_tensor_id(); |
| 87 | |
| 88 | GpuLanguage _gpu_language; |
| 89 | CLCompileContext *_cl_compile_ctx; |
| 90 | |
| 91 | ITensorInfo::Id _next_tensor_id; |
| 92 | MemoryDescriptorMap _mem_map; |
| 93 | }; |
| 94 | |
| 95 | } // namespace dynamic_fusion |
| 96 | } // namespace experimental |
| 97 | } // namespace arm_compute |
| 98 | |
| 99 | #endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADCONTEXTIMPL_H |