ArmNN
 25.11
Loading...
Searching...
No Matches
RefComparisonWorkload.cpp
Go to the documentation of this file.
1//
2// Copyright © 2019-2024 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
7
8#include "Decoders.hpp"
10#include "Encoders.hpp"
11#include "RefWorkloadUtils.hpp"
12
13#include <Profiling.hpp>
14
15#include <armnn/TypesUtils.hpp>
16
17#include <functional>
18
19namespace armnn
20{
21
26
31
32void RefComparisonWorkload::PostAllocationConfigure(std::vector<ITensorHandle*> inputs,
33 std::vector<ITensorHandle*> outputs)
34{
35 const TensorInfo& inputInfo0 = GetTensorInfo(inputs[0]);
36 const TensorInfo& inputInfo1 = GetTensorInfo(inputs[1]);
37 const TensorInfo& outputInfo = GetTensorInfo(outputs[0]);
38
39 m_Input0 = MakeDecoder<InType>(inputInfo0);
40 m_Input1 = MakeDecoder<InType>(inputInfo1);
41
42 m_Output = MakeEncoder<OutType>(outputInfo);
43}
44
46{
47 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
48}
49
50void RefComparisonWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
51{
52 ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefComparisonWorkload_Execute");
53
54 const TensorInfo& inputInfo0 = GetTensorInfo(inputs[0]);
55 const TensorInfo& inputInfo1 = GetTensorInfo(inputs[1]);
56 const TensorInfo& outputInfo = GetTensorInfo(outputs[0]);
57
58 const TensorShape& inShape0 = inputInfo0.GetShape();
59 const TensorShape& inShape1 = inputInfo1.GetShape();
60 const TensorShape& outShape = outputInfo.GetShape();
61
62 m_Input0->Reset(inputs[0]->Map());
63 m_Input1->Reset(inputs[1]->Map());
64 m_Output->Reset(outputs[0]->Map());
65
68 using GreaterOrEqualFunction = ElementwiseBinaryFunction<std::greater_equal<InType>>;
70 using LessOrEqualFunction = ElementwiseBinaryFunction<std::less_equal<InType>>;
72
74 {
76 {
77 EqualFunction(inShape0, inShape1, outShape, *m_Input0, *m_Input1, *m_Output);
78 break;
79 }
81 {
82 GreaterFunction(inShape0, inShape1, outShape, *m_Input0, *m_Input1, *m_Output);
83 break;
84 }
86 {
87 GreaterOrEqualFunction(inShape0, inShape1, outShape, *m_Input0, *m_Input1, *m_Output);
88 break;
89 }
91 {
92 LessFunction(inShape0, inShape1, outShape, *m_Input0, *m_Input1, *m_Output);
93 break;
94 }
96 {
97 LessOrEqualFunction(inShape0, inShape1, outShape, *m_Input0, *m_Input1, *m_Output);
98 break;
99 }
101 {
102 NotEqualFunction(inShape0, inShape1, outShape, *m_Input0, *m_Input1, *m_Output);
103 break;
104 }
105 default:
106 {
107 throw InvalidArgumentException(std::string("Unsupported comparison operation ") +
108 GetComparisonOperationAsCString(m_Data.m_Parameters.m_Operation), CHECK_LOCATION());
109 }
110 }
111}
112
113} // namespace armnn
#define CHECK_LOCATION()
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
RefBaseWorkload(const ComparisonQueueDescriptor &descriptor, const WorkloadInfo &info)
RefComparisonWorkload(const ComparisonQueueDescriptor &descriptor, const WorkloadInfo &info)
const TensorShape & GetShape() const
Definition Tensor.hpp:193
Copyright (c) 2021 ARM Limited and Contributors.
constexpr char const * GetComparisonOperationAsCString(ComparisonOperation operation)
std::unique_ptr< Decoder< T > > MakeDecoder(const TensorInfo &info, const void *data=nullptr)
std::unique_ptr< Encoder< T > > MakeEncoder(const TensorInfo &info, void *data=nullptr)
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
ComparisonOperation m_Operation
Specifies the comparison operation to execute.
Contains information about TensorInfos of a layer.