diff options
author | Kevin May <kevin.may@arm.com> | 2019-09-09 14:46:41 +0100 |
---|---|---|
committer | Kevin May <kevin.may@arm.com> | 2019-09-09 14:46:41 +0100 |
commit | 407718f768417ce9b858224261cb62c742ec80d0 (patch) | |
tree | d49414677748b40bea638aa64af4e2dd2d6448b9 /ConversionUtils.hpp | |
parent | 701d9a0b7316d9b31e05f9238fd8b389d89066ee (diff) | |
download | android-nn-driver-407718f768417ce9b858224261cb62c742ec80d0.tar.gz |
IVGCVSW-3746 Add Android NN Driver support for ABS
Signed-off-by: Kevin May <kevin.may@arm.com>
Change-Id: Icd32bf6f4d5f58e689b55c1c71b0d028155603c8
Diffstat (limited to 'ConversionUtils.hpp')
-rw-r--r-- | ConversionUtils.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp index cc06ccee..683da5e4 100644 --- a/ConversionUtils.hpp +++ b/ConversionUtils.hpp @@ -3237,4 +3237,50 @@ bool ConvertSpaceToBatchNd(const HalOperation& operation, const HalModel& model, return SetupAndTrackLayerOutputSlot<HalPolicy>(operation, 0, *layer, model, data); } +template<typename HalPolicy, + typename HalOperation = typename HalPolicy::Operation, + typename HalModel = typename HalPolicy::Model> +bool ConvertAbs(const HalOperation& operation, const HalModel& model, ConversionData& data) +{ + LayerInputHandle input = ConvertToLayerInputHandle<HalPolicy>(operation, 0, model, data); + + if (!input.IsValid()) + { + return Fail("%s: Operation has invalid input", __func__); + } + + using HalOperand = typename HalPolicy::Operand; + const HalOperand* output = GetOutputOperand<HalPolicy>(operation, 0, model); + if (!output) + { + return Fail("%s: Could not read output 0", __func__); + } + + const armnn::TensorInfo& outputInfo = GetTensorInfoForOperand(*output); + if (IsDynamicTensor(outputInfo)) + { + return Fail("%s: Dynamic output tensors are not supported", __func__); + } + + bool isSupported = false; + FORWARD_LAYER_SUPPORT_FUNC(__func__, + IsAbsSupported, + data.m_Backends, + isSupported, + input.GetTensorInfo(), + outputInfo); + + if (!isSupported) + { + return false; + } + + armnn::IConnectableLayer* const layer = data.m_Network->AddAbsLayer(); + assert(layer != nullptr); + input.Connect(layer->GetInputSlot(0)); + + return SetupAndTrackLayerOutputSlot<HalPolicy>(operation, 0, *layer, model, data); +} + + } // namespace armnn_driver |