James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 1 | // |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefLogicalUnaryWorkload.hpp" |
| 7 | |
| 8 | #include "Decoders.hpp" |
| 9 | #include "ElementwiseFunction.hpp" |
| 10 | #include "Encoders.hpp" |
| 11 | #include "RefWorkloadUtils.hpp" |
| 12 | |
| 13 | #include <Profiling.hpp> |
| 14 | |
| 15 | #include <armnn/TypesUtils.hpp> |
| 16 | |
| 17 | namespace armnn |
| 18 | { |
| 19 | |
| 20 | RefLogicalUnaryWorkload::RefLogicalUnaryWorkload(const ElementwiseUnaryQueueDescriptor& desc, |
| 21 | const WorkloadInfo& info) |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 22 | : RefBaseWorkload<ElementwiseUnaryQueueDescriptor>(desc, info) |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 23 | {} |
| 24 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 25 | void RefLogicalUnaryWorkload::Execute() const |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 26 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 27 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 30 | void RefLogicalUnaryWorkload::ExecuteAsync(ExecutionData& executionData) |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 31 | { |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 32 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 33 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void RefLogicalUnaryWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 37 | { |
| 38 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefLogicalUnaryWorkload_Execute"); |
| 39 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 40 | const TensorInfo& inputInfo = GetTensorInfo(inputs[0]); |
| 41 | const TensorInfo& outputInfo = GetTensorInfo(outputs[0]); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 42 | |
| 43 | const TensorShape& inShape = inputInfo.GetShape(); |
| 44 | const TensorShape& outShape = outputInfo.GetShape(); |
| 45 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 46 | std::unique_ptr<Decoder<InType>> input = MakeDecoder<InType>(inputInfo, inputs[0]->Map()); |
| 47 | std::unique_ptr<Encoder<OutType>> output = MakeEncoder<OutType>(outputInfo, outputs[0]->Map()); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 48 | |
| 49 | using NotFunction = LogicalUnaryFunction<std::logical_not<bool>>; |
| 50 | |
| 51 | switch (m_Data.m_Parameters.m_Operation) |
| 52 | { |
| 53 | case UnaryOperation::LogicalNot: |
| 54 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 55 | NotFunction(inShape, outShape, *input, *output); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 56 | break; |
| 57 | } |
| 58 | default: |
| 59 | { |
| 60 | throw InvalidArgumentException(std::string("Unsupported Logical Unary operation") + |
| 61 | GetUnaryOperationAsCString(m_Data.m_Parameters.m_Operation), CHECK_LOCATION()); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | } // namespace armnn |