ArmNN
 22.11
RefArgMinMaxWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "ArgMinMax.hpp"
9 #include "RefWorkloadUtils.hpp"
10 #include "Decoders.hpp"
11 #include "Encoders.hpp"
12 #include "Profiling.hpp"
13 
14 namespace armnn
15 {
17  const ArgMinMaxQueueDescriptor& descriptor,
18  const WorkloadInfo& info)
19  : RefBaseWorkload<ArgMinMaxQueueDescriptor>(descriptor, info) {}
20 
21 
23 {
25 }
26 
28 {
29  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
30  Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
31 }
32 
33 void RefArgMinMaxWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
34 {
35  ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefArgMinMaxWorkload_Execute");
36 
37  const TensorInfo &inputTensorInfo = GetTensorInfo(inputs[0]);
38 
39  std::unique_ptr<Decoder<float>> decoderPtr = MakeDecoder<float>(inputTensorInfo, inputs[0]->Map());
40  Decoder<float> &decoder = *decoderPtr;
41 
42  const TensorInfo &outputTensorInfo = GetTensorInfo(outputs[0]);
43 
44  if (outputTensorInfo.GetDataType() == armnn::DataType::Signed32) {
45  int32_t *output = GetOutputTensorData<int32_t>(outputs[0]);
46  ArgMinMax(decoder, output, inputTensorInfo, outputTensorInfo, m_Data.m_Parameters.m_Function,
48  } else {
49  int64_t *output = GetOutputTensorData<int64_t>(outputs[0]);
50  ArgMinMax(decoder, output, inputTensorInfo, outputTensorInfo, m_Data.m_Parameters.m_Function,
52  }
53 }
54 
55 } //namespace armnn
CPU Execution: Reference C++ kernels.
ArgMinMaxFunction m_Function
Specify if the function is to find Min or Max.
Definition: Descriptors.hpp:81
Copyright (c) 2021 ARM Limited and Contributors.
void ExecuteAsync(ExecutionData &executionData) override
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
DataType GetDataType() const
Definition: Tensor.hpp:198
std::vector< ITensorHandle * > m_Outputs
RefArgMinMaxWorkload(const ArgMinMaxQueueDescriptor &descriptor, const WorkloadInfo &info)
Contains information about TensorInfos of a layer.
int m_Axis
Axis to reduce across the input tensor.
Definition: Descriptors.hpp:83
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers