diff options
Diffstat (limited to 'src/armnnDeserializer')
-rw-r--r-- | src/armnnDeserializer/Deserializer.cpp | 23 | ||||
-rw-r--r-- | src/armnnDeserializer/Deserializer.hpp | 1 | ||||
-rw-r--r-- | src/armnnDeserializer/DeserializerSupport.md | 1 | ||||
-rw-r--r-- | src/armnnDeserializer/test/DeserializeAbs.cpp | 120 |
4 files changed, 145 insertions, 0 deletions
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp index ef1235745c..8572023fc4 100644 --- a/src/armnnDeserializer/Deserializer.cpp +++ b/src/armnnDeserializer/Deserializer.cpp @@ -185,6 +185,7 @@ Deserializer::Deserializer() m_ParserFunctions(Layer_MAX+1, &Deserializer::ParseUnsupportedLayer) { // register supported layers + m_ParserFunctions[Layer_AbsLayer] = &Deserializer::ParseAbs; m_ParserFunctions[Layer_ActivationLayer] = &Deserializer::ParseActivation; m_ParserFunctions[Layer_AdditionLayer] = &Deserializer::ParseAdd; m_ParserFunctions[Layer_BatchToSpaceNdLayer] = &Deserializer::ParseBatchToSpaceNd; @@ -237,6 +238,8 @@ Deserializer::LayerBaseRawPtr Deserializer::GetBaseLayer(const GraphPtr& graphPt switch(layerType) { + case Layer::Layer_AbsLayer: + return graphPtr->layers()->Get(layerIndex)->layer_as_AbsLayer()->base(); case Layer::Layer_ActivationLayer: return graphPtr->layers()->Get(layerIndex)->layer_as_ActivationLayer()->base(); case Layer::Layer_AdditionLayer: @@ -851,6 +854,26 @@ void Deserializer::RegisterOutputSlotOfConnection(uint32_t sourceLayerIndex, connections.outputSlots[outputSlotIndex] = outputSlot; } +void Deserializer::ParseAbs(armnnDeserializer::Deserializer::GraphPtr graph, unsigned int layerIndex) +{ + CHECK_LAYERS(graph, 0, layerIndex); + auto inputs = GetInputs(graph, layerIndex); + CHECK_LOCATION(); + CHECK_VALID_SIZE(inputs.size(), 1); + + auto outputs = GetOutputs(graph, layerIndex); + CHECK_VALID_SIZE(outputs.size(), 1); + + auto layerName = GetLayerName(graph, layerIndex); + + IConnectableLayer* layer = m_Network->AddAbsLayer(layerName.c_str()); + armnn::TensorInfo outputTensorInfo = ToTensorInfo(outputs[0]); + layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo); + + RegisterInputSlots(graph, layerIndex, layer); + RegisterOutputSlots(graph, layerIndex, layer); +} + void Deserializer::ParseActivation(GraphPtr graph, unsigned int layerIndex) { CHECK_LAYERS(graph, 0, layerIndex); diff --git a/src/armnnDeserializer/Deserializer.hpp b/src/armnnDeserializer/Deserializer.hpp index 591447de21..9ec59fba7a 100644 --- a/src/armnnDeserializer/Deserializer.hpp +++ b/src/armnnDeserializer/Deserializer.hpp @@ -77,6 +77,7 @@ private: using LayerParsingFunction = void(Deserializer::*)(GraphPtr graph, unsigned int layerIndex); void ParseUnsupportedLayer(GraphPtr graph, unsigned int layerIndex); + void ParseAbs(GraphPtr graph, unsigned int layerIndex); void ParseActivation(GraphPtr graph, unsigned int layerIndex); void ParseAdd(GraphPtr graph, unsigned int layerIndex); void ParseBatchToSpaceNd(GraphPtr graph, unsigned int layerIndex); diff --git a/src/armnnDeserializer/DeserializerSupport.md b/src/armnnDeserializer/DeserializerSupport.md index 1bda123284..c780071461 100644 --- a/src/armnnDeserializer/DeserializerSupport.md +++ b/src/armnnDeserializer/DeserializerSupport.md @@ -6,6 +6,7 @@ This reference guide provides a list of layers which can be deserialized current The Arm NN SDK Deserialize parser currently supports the following layers: +* Abs * Activation * Addition * BatchToSpaceNd diff --git a/src/armnnDeserializer/test/DeserializeAbs.cpp b/src/armnnDeserializer/test/DeserializeAbs.cpp new file mode 100644 index 0000000000..4d6504bc10 --- /dev/null +++ b/src/armnnDeserializer/test/DeserializeAbs.cpp @@ -0,0 +1,120 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include <boost/test/unit_test.hpp> +#include "ParserFlatbuffersSerializeFixture.hpp" +#include "../Deserializer.hpp" + +#include <string> +#include <iostream> + +BOOST_AUTO_TEST_SUITE(Deserializer) + + struct AbsFixture : public ParserFlatbuffersSerializeFixture + { + explicit AbsFixture(const std::string &inputShape, + const std::string &outputShape, + const std::string &dataType) + { + m_JsonString = R"( + { + inputIds: [0], + outputIds: [2], + layers: [ + { + layer_type: "InputLayer", + layer: { + base: { + layerBindingId: 0, + base: { + index: 0, + layerName: "InputLayer", + layerType: "Input", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:0, outputSlotIndex:0 }, + }], + outputSlots: [{ + index: 0, + tensorInfo: { + dimensions: )" + inputShape + R"(, + dataType: )" + dataType + R"( + } + }] + } + } + } + }, + { + layer_type: "AbsLayer", + layer: { + base: { + index: 1, + layerName: "AbsLayer", + layerType: "Abs", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:0, outputSlotIndex:0 }, + }], + outputSlots: [{ + index: 0, + tensorInfo: { + dimensions: )" + outputShape + R"(, + dataType: )" + dataType + R"( + } + }] + } + + } + }, + { + layer_type: "OutputLayer", + layer: { + base:{ + layerBindingId: 2, + base: { + index: 2, + layerName: "OutputLayer", + layerType: "Output", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:1, outputSlotIndex:0 }, + }], + outputSlots: [{ + index: 0, + tensorInfo: { + dimensions: )" + outputShape + R"(, + dataType: )" + dataType + R"( + }, + }], + } + } + }, + } + ] + } + )"; + Setup(); + } + }; + + struct SimpleAbsFixture : AbsFixture + { + SimpleAbsFixture() + : AbsFixture("[ 1, 2, 2, 2 ]", // inputShape + "[ 1, 2, 2, 2 ]", // outputShape + "Float32") // dataType + {} + }; + + BOOST_FIXTURE_TEST_CASE(SimpleAbsTest, SimpleAbsFixture) + { + RunTest<4, armnn::DataType::Float32>( + 0, + {{"InputLayer", { -100.0f, -50.5f, -25.9999f, -0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}}, + {{"OutputLayer", { 100.0f, 50.0f, 25.9999f, 0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}}); + } + +BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file |