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 | |
| 25 | void RefLogicalUnaryWorkload::PostAllocationConfigure() |
| 26 | { |
| 27 | const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]); |
| 28 | const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]); |
| 29 | |
| 30 | m_Input = MakeDecoder<InType>(inputInfo); |
| 31 | m_Output = MakeEncoder<OutType>(outputInfo); |
| 32 | } |
| 33 | |
| 34 | void RefLogicalUnaryWorkload::Execute() const |
| 35 | { |
| 36 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefLogicalUnaryWorkload_Execute"); |
| 37 | |
| 38 | const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]); |
| 39 | const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]); |
| 40 | |
| 41 | const TensorShape& inShape = inputInfo.GetShape(); |
| 42 | const TensorShape& outShape = outputInfo.GetShape(); |
| 43 | |
| 44 | m_Input->Reset(m_Data.m_Inputs[0]->Map()); |
| 45 | m_Output->Reset(m_Data.m_Outputs[0]->Map()); |
| 46 | |
| 47 | using NotFunction = LogicalUnaryFunction<std::logical_not<bool>>; |
| 48 | |
| 49 | switch (m_Data.m_Parameters.m_Operation) |
| 50 | { |
| 51 | case UnaryOperation::LogicalNot: |
| 52 | { |
| 53 | NotFunction(inShape, outShape, *m_Input, *m_Output); |
| 54 | break; |
| 55 | } |
| 56 | default: |
| 57 | { |
| 58 | throw InvalidArgumentException(std::string("Unsupported Logical Unary operation") + |
| 59 | GetUnaryOperationAsCString(m_Data.m_Parameters.m_Operation), CHECK_LOCATION()); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | } // namespace armnn |