24.02.1
|
Go to the documentation of this file.
24 #ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSOURCECODE
25 #define SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSOURCECODE
35 namespace experimental
37 namespace dynamic_fusion
39 #ifdef ACL_INTERNAL_TEST_CKW_IN_DF
49 if (flat_kernel_args.empty())
55 const GpuKernelArgumentBinding &karg_head = flat_kernel_args.front();
56 tensor_kargs.push_back(karg_head);
57 flat_kernel_args.pop_front();
58 const auto tensor_id = karg_head.id();
60 while (!flat_kernel_args.empty())
62 const GpuKernelArgumentBinding &karg = flat_kernel_args.front();
63 if (karg.id() != tensor_id)
67 tensor_kargs.push_back(karg);
68 flat_kernel_args.pop_front();
73 #endif // ACL_INTERNAL_TEST_CKW_IN_DF
86 #ifndef ACL_INTERNAL_TEST_CKW_IN_DF
96 : _tensor_info{
tensor_info}, _mem_desc{mem_desc}, _kernel_arg_info{kernel_arg_info}
99 #else // ACL_INTERNAL_TEST_CKW_IN_DF
107 const MemoryDescriptor &mem_desc,
109 : _tensor_info{
tensor_info}, _mem_desc{mem_desc}, _kernel_args{kernel_args}
112 #endif // ACL_INTERNAL_TEST_CKW_IN_DF
116 return _tensor_info.
id();
121 return &_tensor_info;
126 return &_tensor_info;
138 #ifndef ACL_INTERNAL_TEST_CKW_IN_DF
142 return &_kernel_arg_info;
147 return &_kernel_arg_info;
149 #else // ACL_INTERNAL_TEST_CKW_IN_DF
153 return &_kernel_args;
158 return &_kernel_args;
160 #endif // ACL_INTERNAL_TEST_CKW_IN_DF
174 #ifndef ACL_INTERNAL_TEST_CKW_IN_DF
176 #else // ACL_INTERNAL_TEST_CKW_IN_DF
178 #endif // ACL_INTERNAL_TEST_CKW_IN_DF
212 : _id{
id}, _kernel_code{kernel_code}, _stage{
stage}
259 const auto uwk_id =
static_cast<UnitWorkloadId>(_unit_workloads.size());
261 _unit_workloads.push_back(unit_work);
262 #ifndef ACL_INTERNAL_TEST_CKW_IN_DF
265 for (
const auto &id_arg : kernel_code.
arguments())
267 const auto arg_id = id_arg.first;
268 const auto arg = id_arg.second;
269 _workload_arguments[arg_id] =
271 if (_tensor_uwork_map.find(arg_id) == _tensor_uwork_map.end())
273 _tensor_uwork_map[arg_id] = std::set<UnitWorkloadId>();
275 _tensor_uwork_map[arg_id].insert(uwk_id);
277 #else // ACL_INTERNAL_TEST_CKW_IN_DF
282 tensor_kargs = extract_kernel_args_for_one_tensor(flat_kernel_args);
283 if (tensor_kargs.empty())
289 const auto tensor_id = tensor_kargs.at(0).id();
291 *
context->implementation().get_tensor_info(tensor_id), mem_map.at(tensor_id), tensor_kargs};
292 if (_tensor_uwork_map.find(tensor_id) == _tensor_uwork_map.end())
294 _tensor_uwork_map[tensor_id] = std::set<UnitWorkloadId>();
296 _tensor_uwork_map[tensor_id].insert(uwk_id);
299 #endif // ACL_INTERNAL_TEST_CKW_IN_DF
306 return _unit_workloads.at(
id);
311 std::vector<UnitWorkloadId> ids{};
313 for (
const auto &uwk : _unit_workloads)
315 ids.push_back(uwk.id());
322 return &_workload_arguments.at(t_id);
327 std::vector<ITensorInfo::Id> ids{};
328 for (
const auto &id_tensor : _workload_arguments)
330 ids.push_back(id_tensor.first);
337 const auto unit_work_set = _tensor_uwork_map.at(t_id);
338 return std::vector<UnitWorkloadId>(unit_work_set.begin(), unit_work_set.end());
342 std::vector<GpuUnitWorkload> _unit_workloads{};
343 std::map<ITensorInfo::Id, GpuWorkloadArgument> _workload_arguments{};
344 std::map<ITensorInfo::Id, std::set<UnitWorkloadId>> _tensor_uwork_map{};
Descriptor of a workload tensor memory.
@ Run
Run every time after the first time.
GpuKernelArgumentInfo * kernel_argument_info()
Get GpuKernelArgumentInfo of the argument.
ITensorInfo * tensor_info()
Get ITensorInfo of the argument.
const GpuUnitWorkload & query_unit_workload(UnitWorkloadId id) const
Get a unit workload from its id.
const GpuKernelArgumentInfo * kernel_argument_info() const
Get GpuKernelArgumentInfo of the argument.
Describes all the info related to a workload argument (tensor) in order to:
std::vector< ITensorInfo::Id > tensors() const
Get all tensors in the entire workload.
Container of kernel code to be compiled and run in a GpuUnitWorkload.
bool has_valid_id() const
Check if the tensor id is valid.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
ITensorInfo::Id id() const
Get tensor id within workload.
GpuUnitWorkload()=default
Default constructor.
const GpuWorkloadArgument * query_tensor(ITensorInfo::Id t_id) const
Get a GpuWorkloadArgument from its associated tensor id.
Provide context necessary for the creation and configuration of a workload e.g.
int32_t Id
An id that uniquely identifies an ITensorInfo within some domain (e.g.
UnitWorkloadStage stage() const
Get the stage of the unit workload.
UnitWorkloadId add_unit_workload(const GpuKernelSourceCode &kernel_code, const UnitWorkloadStage &stage, const MemoryDescriptorMap &mem_map, const GpuWorkloadContext *context)
Add a unit workload to the workload code.
MemoryDescriptor * memory_descriptor()
Get MemoryDescriptor of the argument.
Hold the generated kernel source code and other information required to compile and run the workload.
Contain information required to set up a kernel argument at run time.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
GpuWorkloadSourceCode()=default
Default constructor.
const ITensorInfo * tensor_info() const
Get ITensorInfo of the argument.
Describes when a unit workload is run.
UnitWorkloadId id() const
Get the id of the unit workload.
GpuWorkloadArgument(const ITensorInfo &tensor_info, const MemoryDescriptor &mem_desc, const GpuKernelArgumentInfo &kernel_arg_info)
Constructor.
const MemoryDescriptor * memory_descriptor() const
Get MemoryDescriptor of the argument.
Store the tensor's metadata.
int32_t UnitWorkloadId
Uniquely identifies a GpuUnitWorkload within a GpuWorkloadSourceCode.
const GpuKernelSourceCode & code() const
Get reference to the underlying GpuKernelSourceCode.
Copyright (c) 2017-2024 Arm Limited.
GpuWorkloadArgument()=default
Default constructor.
std::vector< UnitWorkloadId > unit_workloads() const
Get all unit workloads sorted in topological order.
bool operator==(const KernelProperties &config0, const KernelProperties &config1)
std::vector< UnitWorkloadId > get_unit_workloads_from_tensor(ITensorInfo::Id t_id) const
Get all unit workloads connected to the tensor with t_id.
@ Prepare
Only run once at the beginning.
ITensorInfo::Id id() const override
Get the workload tensor id of the tensor.
std::map< ITensorInfo::Id, GpuKernelArgument > GpuKernelArgumentList
The argument list of a GpuKernelSourceCode.
Store the tensor's metadata.
bool has_valid_id() const
Check if the workload argument has valid id.
GpuKernelSourceCode & arguments(const GpuKernelArgumentList &arguments)
Set kernel argument list.
GpuUnitWorkload(UnitWorkloadId id, const GpuKernelSourceCode &kernel_code, const UnitWorkloadStage &stage)
Constructor.
std::map< ITensorInfo::Id, MemoryDescriptor > MemoryDescriptorMap
A map from ITensorInfo to their corresponding MemoryDescriptor.
The atomic unit in a Gpu workload.