SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 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_MEMORYDESCRIPTOR |
| 25 | #define ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_MEMORYDESCRIPTOR |
| 26 | |
| 27 | #include "arm_compute/core/ITensorInfo.h" |
| 28 | |
| 29 | namespace arm_compute |
| 30 | { |
| 31 | namespace experimental |
| 32 | { |
| 33 | namespace dynamic_fusion |
| 34 | { |
| 35 | /** Type of memory used by a workload tensor */ |
| 36 | enum class MemoryType |
| 37 | { |
| 38 | User = 0, /**< Memory coming directly from users, e.g. for argument tensors */ |
| 39 | Auxiliary = 1, /**< Additional memory required by the workload tensor, e.g. for temporary tensors */ |
Viet-Hoa Do | b84e253 | 2022-12-13 13:09:10 +0000 | [diff] [blame^] | 40 | NoAlloc = 2, /**< Temporary tile which is not allocated as a whole tensor in the memory */ |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /** Memory information for tensors with @ref MemoryType::Auxiliary. |
| 44 | * This informs how much additional memory is required for auxiliary tensors |
| 45 | */ |
| 46 | struct AuxMemoryInfo |
| 47 | { |
| 48 | AuxMemoryInfo() = default; |
| 49 | |
| 50 | AuxMemoryInfo(size_t size, size_t alignment = 0) noexcept |
| 51 | : size(size), |
| 52 | alignment(alignment) |
| 53 | { |
| 54 | } |
| 55 | |
| 56 | friend bool operator==(const AuxMemoryInfo &info0, const AuxMemoryInfo &info1) |
| 57 | { |
| 58 | return info0.size == info1.size && info0.alignment == info1.alignment; |
| 59 | } |
| 60 | size_t size{ 0 }; /**< Total memory size in bytes */ |
| 61 | size_t alignment{ 0 }; /**< Memory alignment in bytes */ |
| 62 | }; |
| 63 | |
| 64 | /** Descriptor of a workload tensor memory */ |
| 65 | struct MemoryDescriptor |
| 66 | { |
| 67 | MemoryType memory_type{}; /**< Memory Type*/ |
| 68 | AuxMemoryInfo aux_memory_info{}; /**< Auxiliary Tensor Memory Information */ |
| 69 | }; |
| 70 | |
| 71 | /** A map from @ref ITensorInfo to their corresponding @ref MemoryDescriptor */ |
| 72 | using MemoryDescriptorMap = std::map<ITensorInfo::Id, MemoryDescriptor>; |
| 73 | |
| 74 | } // namespace dynamic_fusion |
| 75 | } // namespace experimental |
| 76 | } // namespace arm_compute |
| 77 | #endif /* ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_MEMORYDESCRIPTOR */ |