aboutsummaryrefslogtreecommitdiff
path: root/src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h
diff options
context:
space:
mode:
authorSiCong Li <sicong.li@arm.com>2023-01-12 12:54:49 +0000
committerSiCong Li <sicong.li@arm.com>2023-01-20 15:21:31 +0000
commit5a2bc0169d942f7029d73a3afff1eab18b6f65ef (patch)
treeefa7850199b40109b73b0ee35bb8f57531c983e9 /src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h
parenta18d85c6d2c0025938c2dc10e553eb82c01922f2 (diff)
downloadComputeLibrary-5a2bc0169d942f7029d73a3afff1eab18b6f65ef.tar.gz
Add Auxiliary tensors
The asssign_memory_descriptors method could not automatically assign Auxiliary tensors. Therefore changes are made to allow developers to explicitly mark auxiliary tensors. However, to avoid ambiguity between auxiliary and "intermediate" tensors, we solidify the definitions of both: Intermediate tensors are a strictly topological term. They are defined as "inner" tensors within a workload, hidden from the user, as opposed to input and output tensors exposed to the users. Auxiliary tensors are a subcategory of Intermediate tensors, and are also about memory allocation. They are intermediate tensors that need real memory backing. For more details please see the documentation of MemoryType enum Rename MemoryType::NoAlloc to MemoryType::Virtual Partially resolves: COMPMID-5523 Signed-off-by: SiCong Li <sicong.li@arm.com> Change-Id: Ibde44c2ec1570be9423e0fb38b53bb136ffc36dd Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8940 Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Diffstat (limited to 'src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h')
-rw-r--r--src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h b/src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h
index 08796b607b..d5075d5c94 100644
--- a/src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h
+++ b/src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h
@@ -24,6 +24,7 @@
#ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCHIMPL
#define SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCHIMPL
+#include "arm_compute/dynamic_fusion/sketch/MemoryDescriptor.h"
#include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadSketch.h"
#include "src/dynamic_fusion/sketch/gpu/GpuComponentServices.h"
#include "src/dynamic_fusion/sketch/gpu/GpuKernelComponentGraph.h"
@@ -52,7 +53,8 @@ public:
_comp_services{},
_component_graph{ &_comp_services },
_operator_group{},
- _interm_tensor_info_list{ std::vector<std::unique_ptr<TensorInfo>>() }
+ _managed_tensor_info_list{ std::vector<std::unique_ptr<TensorInfo>>() },
+ _mem_map{}
{
}
/** Prevent instances of this class from being copy constructed */
@@ -99,18 +101,47 @@ public:
*/
GpuWorkloadSourceCode generate_source_code() const
{
- return component_graph().fuse().write_workload_code();
+ return component_graph().fuse(_mem_map).write_workload_code();
}
- /** Create an intermediate tensor info and save it
+ /** Create a virtual (see @ref MemoryType) tensor info and save it
*
- * @return ITensorInfo The created intermediate tensor info object pointer
+ * @return ITensorInfo* The created virtual tensor info object pointer
*/
- ITensorInfo *create_intermediate_tensor()
+ ITensorInfo *create_virtual_tensor()
{
auto uptr = std::make_unique<TensorInfo>();
- uptr->set_id(-allocate_new_tensor_id()); // intermediate tensors must have negative id
- _interm_tensor_info_list.emplace_back(std::move(uptr));
- return _interm_tensor_info_list.back().get();
+ uptr->set_id(-allocate_new_tensor_id()); // virtual tensors must have negative id
+ register_memory_descriptor(*uptr, MemoryDescriptor{ MemoryType::Virtual });
+ _managed_tensor_info_list.emplace_back(std::move(uptr));
+ return _managed_tensor_info_list.back().get();
+ }
+ /** Create an auxiliary (see @ref MemoryType) tensor info and save it
+ *
+ * @return ITensorInfo* The created auxiliary tensor info object pointer
+ */
+
+ /** Create an auxiliary (see @ref MemoryType) tensor info and save it
+ *
+ * @param[in] tensor_info @ref ITensorInfo to copy from
+ *
+ * @return ITensorInfo* The created auxiliary tensor info object pointer
+ */
+ ITensorInfo *create_auxiliary_tensor(const ITensorInfo &tensor_info)
+ {
+ auto uptr = std::make_unique<TensorInfo>(tensor_info);
+ uptr->set_id(allocate_new_tensor_id());
+ register_memory_descriptor(*uptr, MemoryDescriptor{ MemoryType::Auxiliary, AuxMemoryInfo{ uptr->total_size() } });
+ _managed_tensor_info_list.emplace_back(std::move(uptr));
+ return _managed_tensor_info_list.back().get();
+ }
+ /** Register memory descriptor of a tensor info
+ *
+ * @param[in] info @ref ITensorInfo to be registered
+ * @param[in] mem_desc @ref MemoryDescriptor to be registered with @p info
+ */
+ void register_memory_descriptor(const ITensorInfo &info, const MemoryDescriptor &mem_desc)
+ {
+ _mem_map[info.id()] = mem_desc;
}
private:
@@ -119,7 +150,8 @@ private:
GpuKernelComponentGraph _component_graph;
GpuOperatorGroup _operator_group;
ITensorInfo::Id _next_id{ ITensorInfo::invalid_tensor_id };
- std::vector<std::unique_ptr<TensorInfo>> _interm_tensor_info_list;
+ std::vector<std::unique_ptr<TensorInfo>> _managed_tensor_info_list;
+ MemoryDescriptorMap _mem_map;
};
} // namespace dynamic_fusion
} // namespace experimental