ArmNN
 24.08
RefScatterNdWorkload.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 
6 #include <fmt/format.h>
8 #include "RefWorkloadUtils.hpp"
9 #include "ScatterNd.hpp"
10 #include "Profiling.hpp"
11 
12 namespace armnn
13 {
14 
16  : RefBaseWorkload(descriptor, info)
17  {}
18 
20  {
22  }
23 
25  {
26  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
27  Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
28  }
29 
30  void RefScatterNdWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
31  {
32  ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefScatterNdWorkload_Execute");
33 
35  {
36  // Getting TensorInfos for three inputs slots
37  const TensorInfo& inputInfo = GetTensorInfo(inputs[0]);
38  const TensorInfo& indicesInfo = GetTensorInfo(inputs[1]);
39  const TensorInfo& updatesInfo = GetTensorInfo(inputs[2]);
40 
41  // Getting Decoder for input
42  std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]),
43  inputs[0]->Map());
44 
45  // Getting Decoder for indices
46  std::unique_ptr<Decoder<int>> indicesDecoder = MakeDecoder<int>(GetTensorInfo(inputs[1]),
47  inputs[1]->Map());
48 
49  // Getting Decoder for updates
50  std::unique_ptr<Decoder<float>> updatesDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]),
51  inputs[2]->Map());
52 
53  // Getting Encoder for output
54  std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]),
55  outputs[0]->Map());
56 
57  ScatterNd(inputInfo,
58  indicesInfo,
59  updatesInfo,
60  *inputDecoder,
61  *indicesDecoder,
62  *updatesDecoder,
63  *outputEncoder,
65  }
66  else
67  {
68  // Getting TensorInfos for three inputs slots
69  const TensorInfo& shapeInfo = GetTensorInfo(inputs[0]);
70  const TensorInfo& indicesInfo = GetTensorInfo(inputs[1]);
71  const TensorInfo& updatesInfo = GetTensorInfo(inputs[2]);
72 
73  // Getting Decoder for shape
74  std::unique_ptr<Decoder<int>> shapeDecoder = MakeDecoder<int>(GetTensorInfo(inputs[0]),
75  inputs[0]->Map());
76 
77  // Getting Decoder for indices
78  std::unique_ptr<Decoder<int>> indicesDecoder = MakeDecoder<int>(GetTensorInfo(inputs[1]),
79  inputs[1]->Map());
80 
81  // Getting Decoder for updates
82  std::unique_ptr<Decoder<float>> updatesDecoder = MakeDecoder<float>(GetTensorInfo(inputs[2]),
83  inputs[2]->Map());
84 
85  // Getting Encoder for output
86  std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]),
87  outputs[0]->Map());
88 
89  ScatterNd(indicesInfo,
90  updatesInfo,
91  shapeInfo,
92  *indicesDecoder,
93  *updatesDecoder,
94  *shapeDecoder,
95  *outputEncoder,
97  }
98  }
99 
100 } // namespace armnn
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
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
Profiling.hpp
ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: RefWorkloadUtils.hpp:22
RefScatterNdWorkload.hpp
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::ScatterNdQueueDescriptor
Definition: WorkloadData.hpp:773
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:33
armnn::RefScatterNdWorkload::Execute
void Execute() const override
Definition: RefScatterNdWorkload.cpp:19
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::ScatterNd
void ScatterNd(const TensorInfo &inputInfo, const TensorInfo &indicesInfo, const TensorInfo &updatesInfo, Decoder< float > &input, Decoder< int > &indices, Decoder< float > &updates, Encoder< float > &output, ScatterNdDescriptor descriptor)
Definition: ScatterNd.cpp:41
RefWorkloadUtils.hpp
ScatterNd.hpp
armnn::BaseWorkload< ScatterNdQueueDescriptor >::m_Data
ScatterNdQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::LayerType::Map
@ Map
armnn::experimental::WorkingMemDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkingMemDescriptor.hpp:20
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::RefScatterNdWorkload::RefScatterNdWorkload
RefScatterNdWorkload(const ScatterNdQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: RefScatterNdWorkload.cpp:15
armnn::experimental::WorkingMemDescriptor
Definition: WorkingMemDescriptor.hpp:18
armnn::RefScatterNdWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefScatterNdWorkload.cpp:24
armnn::RefBaseWorkload
Definition: RefBaseWorkload.hpp:13
armnn::experimental::WorkingMemDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkingMemDescriptor.hpp:21
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::experimental::ExecutionData
Definition: ExecutionData.hpp:14