diff options
author | Kevin May <kevin.may@arm.com> | 2024-02-26 09:12:23 +0000 |
---|---|---|
committer | TeresaARM <teresa.charlinreyes@arm.com> | 2024-03-12 16:59:29 +0000 |
commit | e3cc71663e39a2d46bad3ef7e6c146ff9a9e5b0e (patch) | |
tree | 2559295d707eb88b0370370ccca36f250856a6a5 /src/armnnDeserializer/Deserializer.cpp | |
parent | 70dc5e9dc375c2feb306c7e709078c9f61ef8b1a (diff) | |
download | armnn-e3cc71663e39a2d46bad3ef7e6c146ff9a9e5b0e.tar.gz |
IVGCVSW-8230 Add ScatterNd to Serializer and Deserializer
* Added parsing functions to the serializer and deserializer
* Added ScatterNd and its Descriptor to the ArmnnSchema.fbs
* Added Unittest for Serializer and Deserializer
Signed-off-by: Kevin May <kevin.may@arm.com>
Change-Id: I1ed674dc32d2e2d0d84dca4c7018984ea367ea50
Diffstat (limited to 'src/armnnDeserializer/Deserializer.cpp')
-rw-r--r-- | src/armnnDeserializer/Deserializer.cpp | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp index f27489f339..b77eb0efc0 100644 --- a/src/armnnDeserializer/Deserializer.cpp +++ b/src/armnnDeserializer/Deserializer.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017,2019-2023 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2019-2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -265,6 +265,7 @@ m_ParserFunctions(Layer_MAX+1, &IDeserializer::DeserializerImpl::ParseUnsupporte m_ParserFunctions[Layer_ResizeLayer] = &DeserializerImpl::ParseResize; m_ParserFunctions[Layer_ReverseV2Layer] = &DeserializerImpl::ParseReverseV2; m_ParserFunctions[Layer_RsqrtLayer] = &DeserializerImpl::ParseRsqrt; + m_ParserFunctions[Layer_ScatterNdLayer] = &DeserializerImpl::ParseScatterNd; m_ParserFunctions[Layer_ShapeLayer] = &DeserializerImpl::ParseShape; m_ParserFunctions[Layer_SliceLayer] = &DeserializerImpl::ParseSlice; m_ParserFunctions[Layer_SoftmaxLayer] = &DeserializerImpl::ParseSoftmax; @@ -402,6 +403,8 @@ LayerBaseRawPtr IDeserializer::DeserializerImpl::GetBaseLayer(const GraphPtr& gr return graphPtr->layers()->Get(layerIndex)->layer_as_ReverseV2Layer()->base(); case Layer::Layer_RsqrtLayer: return graphPtr->layers()->Get(layerIndex)->layer_as_RsqrtLayer()->base(); + case Layer::Layer_ScatterNdLayer: + return graphPtr->layers()->Get(layerIndex)->layer_as_ScatterNdLayer()->base(); case Layer::Layer_ShapeLayer: return graphPtr->layers()->Get(layerIndex)->layer_as_ShapeLayer()->base(); case Layer::Layer_SliceLayer: @@ -521,6 +524,25 @@ armnn::ArgMinMaxFunction ToArgMinMaxFunction(armnnSerializer::ArgMinMaxFunction } } +armnn::ScatterNdFunction ToScatterNdFunction(armnnSerializer::ScatterNdFunction function) +{ + switch (function) + { + case armnnSerializer::ScatterNdFunction_Update: + return armnn::ScatterNdFunction::Update; + case armnnSerializer::ScatterNdFunction_Add: + return armnn::ScatterNdFunction::Add; + case armnnSerializer::ScatterNdFunction_Sub: + return armnn::ScatterNdFunction::Sub; + case armnnSerializer::ScatterNdFunction_Max: + return armnn::ScatterNdFunction::Max; + case armnnSerializer::ScatterNdFunction_Min: + return armnn::ScatterNdFunction::Min; + default: + return armnn::ScatterNdFunction::Update; + } +} + armnn::ComparisonOperation ToComparisonOperation(armnnSerializer::ComparisonOperation operation) { switch (operation) @@ -4008,4 +4030,33 @@ void IDeserializer::DeserializerImpl::ParseUnidirectionalSequenceLstm(GraphPtr g RegisterOutputSlots(graph, layerIndex, layer); } +void IDeserializer::DeserializerImpl::ParseScatterNd(GraphPtr graph, unsigned int layerIndex) +{ + CHECK_LAYERS(graph, 0, layerIndex); + auto inputs = GetInputs(graph, layerIndex); + CHECK_LOCATION(); + CHECK_VALID_SIZE(inputs.size(), 3); + + auto outputs = GetOutputs(graph, layerIndex); + CHECK_VALID_SIZE(outputs.size(), 1); + + auto ScatterNdLayer = graph->layers()->Get(layerIndex)->layer_as_ScatterNdLayer(); + auto layerName = GetLayerName(graph, layerIndex); + auto flatBufferDescriptor = ScatterNdLayer->descriptor(); + + armnn::ScatterNdDescriptor scatterNdDescriptor; + scatterNdDescriptor.m_Function = ToScatterNdFunction(flatBufferDescriptor->m_Function()); + scatterNdDescriptor.m_InputEnabled = flatBufferDescriptor->m_InputEnabled(); + scatterNdDescriptor.m_Axis = flatBufferDescriptor->m_Axis(); + scatterNdDescriptor.m_AxisEnabled = flatBufferDescriptor->m_AxisEnabled(); + + IConnectableLayer* layer = m_Network->AddScatterNdLayer(scatterNdDescriptor, layerName.c_str()); + + armnn::TensorInfo output0TensorInfo = ToTensorInfo(outputs[0]); + layer->GetOutputSlot(0).SetTensorInfo(output0TensorInfo); + + RegisterInputSlots(graph, layerIndex, layer); + RegisterOutputSlots(graph, layerIndex, layer); +} + } // namespace armnnDeserializer |