ArmNN
 24.08
ClScatterNdWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2024 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "ClWorkloadUtils.hpp"
9 
11 #include <cl/ClTensorHandle.hpp>
12 
13 #include <arm_compute/function_info/ScatterInfo.h>
14 
15 namespace armnn
16 {
17 
18 using namespace armcomputetensorutils;
19 
21  const TensorInfo& indicesInfo,
22  const TensorInfo& updatesInfo,
23  const TensorInfo& outputInfo,
24  const ScatterNdDescriptor& descriptor)
25 {
26  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(inputInfo);
27  const arm_compute::TensorInfo aclIndicesInfo = BuildArmComputeTensorInfo(indicesInfo);
28  const arm_compute::TensorInfo aclUpdatesInfo = BuildArmComputeTensorInfo(updatesInfo);
29  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(outputInfo);
30 
31  arm_compute::ScatterInfo scatterInfo = BuildArmComputeScatterInfo(descriptor);
32 
33  return arm_compute::CLScatter::validate(descriptor.m_InputEnabled ? &aclInputInfo : nullptr,
34  &aclUpdatesInfo,
35  &aclIndicesInfo,
36  &aclOutputInfo,
37  scatterInfo);
38 }
39 
41  const WorkloadInfo& info,
42  const arm_compute::CLCompileContext& clCompileContext)
44 {
45  // Report Profiling Details
46  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClScatterNdWorkload_Construct",
47  descriptor.m_Parameters,
48  info,
49  this->GetGuid());
50 
51  m_Data.ValidateInputsOutputs("ClScatterNdWorkload", 3, 1);
52 
53  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
54  arm_compute::ICLTensor& updates = static_cast<IClTensorHandle*>(m_Data.m_Inputs[2])->GetTensor();
55  arm_compute::ICLTensor& indices = static_cast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
56  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
57 
58  arm_compute::ScatterInfo scatterInfo = BuildArmComputeScatterInfo(descriptor.m_Parameters);
59 
60  {
61  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClScatterNdWorkload_configure");
62  m_ScatterNdLayer.configure(clCompileContext,
63  descriptor.m_Parameters.m_InputEnabled ? &input : nullptr,
64  &updates,
65  &indices,
66  &output,
67  scatterInfo);
68  }
69 }
70 
72 {
73  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClScatterNdWorkload_Execute");
74  RunClFunction(m_ScatterNdLayer, CHECK_LOCATION());
75 }
76 
77 } //namespace armnn
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:447
armnn::ScatterNdDescriptor::m_InputEnabled
bool m_InputEnabled
Flag to show if input tensor is accepted.
Definition: Descriptors.hpp:1722
armnn::TensorInfo
Definition: Tensor.hpp:152
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnn::ClBaseWorkload
Definition: ClBaseWorkload.hpp:13
armnn::ClScatterNdWorkload::Execute
void Execute() const override
Definition: ClScatterNdWorkload.cpp:71
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: ClWorkloadUtils.hpp:36
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::ScatterNdQueueDescriptor
Definition: WorkloadData.hpp:773
ClWorkloadUtils.hpp
armnn::ClScatterNdWorkloadValidate
arm_compute::Status ClScatterNdWorkloadValidate(const TensorInfo &inputInfo, const TensorInfo &indicesInfo, const TensorInfo &updatesInfo, const TensorInfo &outputInfo, const ScatterNdDescriptor &descriptor)
Definition: ClScatterNdWorkload.cpp:20
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::IClTensorHandle
Definition: IClTensorHandle.hpp:13
armnn::Status
Status
Definition: Types.hpp:42
ClTensorHandle.hpp
armnn::BaseWorkload< ScatterNdQueueDescriptor >::m_Data
ScatterNdQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::RunClFunction
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
Definition: ClWorkloadUtils.hpp:167
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
armnn::ScatterNdDescriptor
A ScatterNdDescriptor for the ScatterNdLayer.
Definition: Descriptors.hpp:1679
ClScatterNdWorkload.hpp
armnn::ClScatterNdWorkload::ClScatterNdWorkload
ClScatterNdWorkload(const ScatterNdQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Definition: ClScatterNdWorkload.cpp:40
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26