James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 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) |
| 22 | : BaseWorkload<ElementwiseUnaryQueueDescriptor>(desc, info) |
| 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 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 30 | void RefLogicalUnaryWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 31 | { |
| 32 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 33 | } |
| 34 | |
| 35 | void RefLogicalUnaryWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 36 | { |
| 37 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefLogicalUnaryWorkload_Execute"); |
| 38 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 39 | const TensorInfo& inputInfo = GetTensorInfo(inputs[0]); |
| 40 | const TensorInfo& outputInfo = GetTensorInfo(outputs[0]); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 41 | |
| 42 | const TensorShape& inShape = inputInfo.GetShape(); |
| 43 | const TensorShape& outShape = outputInfo.GetShape(); |
| 44 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 45 | std::unique_ptr<Decoder<InType>> input = MakeDecoder<InType>(inputInfo, inputs[0]->Map()); |
| 46 | std::unique_ptr<Encoder<OutType>> output = MakeEncoder<OutType>(outputInfo, outputs[0]->Map()); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 47 | |
| 48 | using NotFunction = LogicalUnaryFunction<std::logical_not<bool>>; |
| 49 | |
| 50 | switch (m_Data.m_Parameters.m_Operation) |
| 51 | { |
| 52 | case UnaryOperation::LogicalNot: |
| 53 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 54 | NotFunction(inShape, outShape, *input, *output); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 55 | break; |
| 56 | } |
| 57 | default: |
| 58 | { |
| 59 | throw InvalidArgumentException(std::string("Unsupported Logical Unary operation") + |
| 60 | GetUnaryOperationAsCString(m_Data.m_Parameters.m_Operation), CHECK_LOCATION()); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | } // namespace armnn |