diff options
Diffstat (limited to 'src/armnnSerializer')
-rw-r--r-- | src/armnnSerializer/ArmnnSchema.fbs | 11 | ||||
-rw-r--r-- | src/armnnSerializer/Serializer.cpp | 28 | ||||
-rw-r--r-- | src/armnnSerializer/Serializer.hpp | 4 | ||||
-rw-r--r-- | src/armnnSerializer/test/SerializerTests.cpp | 25 |
4 files changed, 68 insertions, 0 deletions
diff --git a/src/armnnSerializer/ArmnnSchema.fbs b/src/armnnSerializer/ArmnnSchema.fbs index 75dd252e68..bd0bd0380d 100644 --- a/src/armnnSerializer/ArmnnSchema.fbs +++ b/src/armnnSerializer/ArmnnSchema.fbs @@ -187,6 +187,7 @@ enum LayerType : uint { BatchMatMul = 68, ElementwiseBinary = 69, ReverseV2 = 70, + Tile = 71, } // Base layer table to be used as part of other layers @@ -1053,6 +1054,15 @@ table BatchMatMulLayer { descriptor:BatchMatMulDescriptor; } +table TileDescriptor { + m_Multiples:[uint]; +} + +table TileLayer { + base:LayerBase; + descriptor:TileDescriptor; +} + union Layer { ActivationLayer, AdditionLayer, @@ -1125,6 +1135,7 @@ union Layer { BatchMatMulLayer, ElementwiseBinaryLayer, ReverseV2Layer, + TileLayer, } table AnyLayer { diff --git a/src/armnnSerializer/Serializer.cpp b/src/armnnSerializer/Serializer.cpp index 39a42954a9..6cadb598a2 100644 --- a/src/armnnSerializer/Serializer.cpp +++ b/src/armnnSerializer/Serializer.cpp @@ -1440,6 +1440,27 @@ void SerializerStrategy::SerializeSwitchLayer(const armnn::IConnectableLayer* la CreateAnyLayer(fbSwitchLayer.o, serializer::Layer::Layer_SwitchLayer); } +void SerializerStrategy::SerializeTileLayer(const armnn::IConnectableLayer* layer, + const armnn::TileDescriptor& descriptor, + const char* name) +{ + IgnoreUnused(name); + + // Create FlatBuffer BaseLayer + auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Tile); + + auto flatBufferDesc = serializer::CreateTileDescriptor(m_flatBufferBuilder, + m_flatBufferBuilder.CreateVector(descriptor.m_Multiples)); + + // Create the FlatBuffer TileLayer + auto flatBufferLayer = serializer::CreateTileLayer(m_flatBufferBuilder, + flatBufferBaseLayer, + flatBufferDesc); + + // Add the AnyLayer to the FlatBufferLayers + CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_TileLayer); +} + void SerializerStrategy::SerializeTransposeConvolution2dLayer( const armnn::IConnectableLayer* layer, const armnn::TransposeConvolution2dDescriptor& descriptor, @@ -2425,6 +2446,13 @@ void SerializerStrategy::ExecuteStrategy(const armnn::IConnectableLayer* layer, SerializeSwitchLayer(layer, name); break; } + case armnn::LayerType::Tile: + { + const armnn::TileDescriptor& layerDescriptor = + static_cast<const armnn::TileDescriptor&>(descriptor); + SerializeTileLayer(layer, layerDescriptor, name); + break; + } case armnn::LayerType::Transpose: { const armnn::TransposeDescriptor& layerDescriptor = diff --git a/src/armnnSerializer/Serializer.hpp b/src/armnnSerializer/Serializer.hpp index 9e9eca8e26..afff66e21a 100644 --- a/src/armnnSerializer/Serializer.hpp +++ b/src/armnnSerializer/Serializer.hpp @@ -337,6 +337,10 @@ private: void SerializeSwitchLayer(const armnn::IConnectableLayer* layer, const char* name = nullptr); + void SerializeTileLayer(const armnn::IConnectableLayer* layer, + const armnn::TileDescriptor& descriptor, + const char* name); + void SerializeTransposeConvolution2dLayer(const armnn::IConnectableLayer* layer, const armnn::TransposeConvolution2dDescriptor& descriptor, const std::vector<armnn::ConstTensor>& constants, diff --git a/src/armnnSerializer/test/SerializerTests.cpp b/src/armnnSerializer/test/SerializerTests.cpp index 163e5c8374..b2590eaa42 100644 --- a/src/armnnSerializer/test/SerializerTests.cpp +++ b/src/armnnSerializer/test/SerializerTests.cpp @@ -3038,5 +3038,30 @@ TEST_CASE("SerializeOverriddenSlot") deserializedNetwork->ExecuteStrategy(verifier); } +TEST_CASE("SerializeTile") +{ + const std::string layerName("Tile"); + const armnn::TensorInfo inputInfo = armnn::TensorInfo({ 2, 3 }, armnn::DataType::Float32); + const armnn::TensorInfo outputInfo = armnn::TensorInfo({ 4, 6 }, armnn::DataType::Float32); + + armnn::TileDescriptor desc = armnn::TileDescriptor(std::vector<uint32_t>{ 2, 2 }); + + armnn::INetworkPtr network = armnn::INetwork::Create(); + armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0); + armnn::IConnectableLayer* const tileLayer = network->AddTileLayer(desc, layerName.c_str()); + armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0); + + inputLayer->GetOutputSlot(0).Connect(tileLayer->GetInputSlot(0)); + tileLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); + + inputLayer->GetOutputSlot(0).SetTensorInfo(inputInfo); + tileLayer->GetOutputSlot(0).SetTensorInfo(outputInfo); + + armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(SerializeNetwork(*network)); + CHECK(deserializedNetwork); + + LayerVerifierBaseWithDescriptor<armnn::TileDescriptor> verifier(layerName, {inputInfo}, {outputInfo}, desc); + deserializedNetwork->ExecuteStrategy(verifier); +} } |