diff options
Diffstat (limited to 'src/armnnSerializer')
-rw-r--r-- | src/armnnSerializer/Serializer.cpp | 70 | ||||
-rw-r--r-- | src/armnnSerializer/Serializer.hpp | 24 | ||||
-rw-r--r-- | src/armnnSerializer/test/SerializerTests.cpp | 75 |
3 files changed, 14 insertions, 155 deletions
diff --git a/src/armnnSerializer/Serializer.cpp b/src/armnnSerializer/Serializer.cpp index efaf9f81cd..7e1b74e10d 100644 --- a/src/armnnSerializer/Serializer.cpp +++ b/src/armnnSerializer/Serializer.cpp @@ -155,15 +155,6 @@ void SerializerStrategy::SerializeOutputLayer(const armnn::IConnectableLayer* la CreateAnyLayer(flatBufferOutputLayer.o, serializer::Layer::Layer_OutputLayer); } -void SerializerStrategy::SerializeAbsLayer(const armnn::IConnectableLayer* layer, const char* name) -{ - IgnoreUnused(name); - auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Abs); - auto flatBufferAbsLayer = serializer::CreateAbsLayer(m_flatBufferBuilder, flatBufferBaseLayer); - - CreateAnyLayer(flatBufferAbsLayer.o, serializer::Layer::Layer_AbsLayer); -} - // Build FlatBuffer for Activation Layer void SerializerStrategy::SerializeActivationLayer(const armnn::IConnectableLayer* layer, const armnn::ActivationDescriptor& descriptor, @@ -570,16 +561,6 @@ void SerializerStrategy::SerializeElementwiseUnaryLayer(const armnn::IConnectabl CreateAnyLayer(fbLayer.o, serializer::Layer::Layer_ElementwiseUnaryLayer); } -void SerializerStrategy::SerializeEqualLayer(const armnn::IConnectableLayer* layer, const char* name) -{ - IgnoreUnused(name); - - auto fbBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Equal); - auto fbEqualLayer = serializer::CreateEqualLayer(m_flatBufferBuilder, fbBaseLayer); - - CreateAnyLayer(fbEqualLayer.o, serializer::Layer::Layer_EqualLayer); -} - void SerializerStrategy::SerializeFillLayer(const armnn::IConnectableLayer* layer, const armnn::FillDescriptor& fillDescriptor, const char* name) @@ -619,17 +600,6 @@ void SerializerStrategy::SerializeGatherLayer(const armnn::IConnectableLayer* la CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_GatherLayer); } - -void SerializerStrategy::SerializeGreaterLayer(const armnn::IConnectableLayer* layer, const char* name) -{ - IgnoreUnused(name); - - auto fbGreaterBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Greater); - auto fbGreaterLayer = serializer::CreateGreaterLayer(m_flatBufferBuilder, fbGreaterBaseLayer); - - CreateAnyLayer(fbGreaterLayer.o, serializer::Layer::Layer_GreaterLayer); -} - void SerializerStrategy::SerializeInstanceNormalizationLayer( const armnn::IConnectableLayer* layer, const armnn::InstanceNormalizationDescriptor& instanceNormalizationDescriptor, @@ -874,13 +844,6 @@ void SerializerStrategy::SerializeMergeLayer(const armnn::IConnectableLayer* lay CreateAnyLayer(fbMergeLayer.o, serializer::Layer::Layer_MergeLayer); } -void SerializerStrategy::SerializeMergerLayer(const armnn::IConnectableLayer* layer, - const armnn::MergerDescriptor& mergerDescriptor, - const char* name) -{ - SerializeConcatLayer(layer, mergerDescriptor, name); -} - void SerializerStrategy::SerializeConcatLayer(const armnn::IConnectableLayer* layer, const armnn::ConcatDescriptor& concatDescriptor, const char* name) @@ -1034,29 +997,6 @@ void SerializerStrategy::SerializeReshapeLayer(const armnn::IConnectableLayer* l CreateAnyLayer(flatBufferReshapeLayer.o, serializer::Layer::Layer_ReshapeLayer); } -void SerializerStrategy::SerializeResizeBilinearLayer(const armnn::IConnectableLayer* layer, - const armnn::ResizeBilinearDescriptor& resizeDescriptor, - const char* name) -{ - IgnoreUnused(name); - - auto flatBufferBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_ResizeBilinear); - - auto flatBufferDescriptor = - CreateResizeBilinearDescriptor(m_flatBufferBuilder, - resizeDescriptor.m_TargetWidth, - resizeDescriptor.m_TargetHeight, - GetFlatBufferDataLayout(resizeDescriptor.m_DataLayout), - resizeDescriptor.m_AlignCorners, - resizeDescriptor.m_HalfPixelCenters); - - auto flatBufferLayer = serializer::CreateResizeBilinearLayer(m_flatBufferBuilder, - flatBufferBaseLayer, - flatBufferDescriptor); - - CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ResizeBilinearLayer); -} - void SerializerStrategy::SerializeResizeLayer(const armnn::IConnectableLayer* layer, const armnn::ResizeDescriptor& resizeDescriptor, const char* name) @@ -1081,16 +1021,6 @@ void SerializerStrategy::SerializeResizeLayer(const armnn::IConnectableLayer* la CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_ResizeLayer); } -void SerializerStrategy::SerializeRsqrtLayer(const armnn::IConnectableLayer* layer, const char* name) -{ - IgnoreUnused(name); - - auto fbRsqrtBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Rsqrt); - auto fbRsqrtLayer = serializer::CreateRsqrtLayer(m_flatBufferBuilder, fbRsqrtBaseLayer); - - CreateAnyLayer(fbRsqrtLayer.o, serializer::Layer::Layer_RsqrtLayer); -} - void SerializerStrategy::SerializeSliceLayer(const armnn::IConnectableLayer* layer, const armnn::SliceDescriptor& sliceDescriptor, const char* name) diff --git a/src/armnnSerializer/Serializer.hpp b/src/armnnSerializer/Serializer.hpp index 1161095c33..2f827ac059 100644 --- a/src/armnnSerializer/Serializer.hpp +++ b/src/armnnSerializer/Serializer.hpp @@ -104,10 +104,6 @@ private: uint32_t m_layerId; private: - ARMNN_DEPRECATED_MSG("Use VisitElementwiseUnaryLayer instead") - void SerializeAbsLayer(const armnn::IConnectableLayer* layer, - const char* name = nullptr); - void SerializeActivationLayer(const armnn::IConnectableLayer* layer, const armnn::ActivationDescriptor& descriptor, const char* name = nullptr); @@ -181,9 +177,6 @@ private: const armnn::ElementwiseUnaryDescriptor& descriptor, const char* name = nullptr); - ARMNN_DEPRECATED_MSG("Use VisitComparisonLayer instead") - void SerializeEqualLayer(const armnn::IConnectableLayer* layer, const char* name); - void SerializeFillLayer(const armnn::IConnectableLayer* layer, const armnn::FillDescriptor& fillDescriptor, const char* name = nullptr); @@ -199,9 +192,6 @@ private: const armnn::GatherDescriptor& gatherDescriptor, const char* name = nullptr); - ARMNN_DEPRECATED_MSG("Use VisitComparisonLayer instead") - void SerializeGreaterLayer(const armnn::IConnectableLayer* layer, const char* name = nullptr); - void SerializeInputLayer(const armnn::IConnectableLayer* layer, armnn::LayerBindingId id, const char* name = nullptr); @@ -240,11 +230,6 @@ private: void SerializeMergeLayer(const armnn::IConnectableLayer* layer, const char* name = nullptr); - ARMNN_DEPRECATED_MSG("Use VisitConcatLayer instead") - void SerializeMergerLayer(const armnn::IConnectableLayer* layer, - const armnn::MergerDescriptor& mergerDescriptor, - const char* name = nullptr); - void SerializeMultiplicationLayer(const armnn::IConnectableLayer* layer, const char* name = nullptr); @@ -294,15 +279,6 @@ private: const armnn::ResizeDescriptor& resizeDescriptor, const char* name = nullptr); - ARMNN_DEPRECATED_MSG("Use VisitResizeLayer instead") - void SerializeResizeBilinearLayer(const armnn::IConnectableLayer* layer, - const armnn::ResizeBilinearDescriptor& resizeDescriptor, - const char* name = nullptr); - - ARMNN_DEPRECATED_MSG("Use VisitElementwiseUnaryLayer instead") - void SerializeRsqrtLayer(const armnn::IConnectableLayer* layer, - const char* name = nullptr); - void SerializeSliceLayer(const armnn::IConnectableLayer* layer, const armnn::SliceDescriptor& sliceDescriptor, const char* name = nullptr); diff --git a/src/armnnSerializer/test/SerializerTests.cpp b/src/armnnSerializer/test/SerializerTests.cpp index 2f8fd73717..f2c9852607 100644 --- a/src/armnnSerializer/test/SerializerTests.cpp +++ b/src/armnnSerializer/test/SerializerTests.cpp @@ -748,7 +748,7 @@ TEST_CASE("SerializeDivision") deserializedNetwork->ExecuteStrategy(verifier); } -TEST_CASE("SerializeDeserializeEqual") +TEST_CASE("SerializeDeserializeComparisonEqual") { const std::string layerName("EqualLayer"); const armnn::TensorInfo inputTensorInfo1 = armnn::TensorInfo({2, 1, 2, 4}, armnn::DataType::Float32); @@ -758,9 +758,8 @@ TEST_CASE("SerializeDeserializeEqual") armnn::INetworkPtr network = armnn::INetwork::Create(); armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(0); armnn::IConnectableLayer* const inputLayer2 = network->AddInputLayer(1); - ARMNN_NO_DEPRECATE_WARN_BEGIN - armnn::IConnectableLayer* const equalLayer = network->AddEqualLayer(layerName.c_str()); - ARMNN_NO_DEPRECATE_WARN_END + armnn::ComparisonDescriptor equalDescriptor(armnn::ComparisonOperation::Equal); + armnn::IConnectableLayer* const equalLayer = network->AddComparisonLayer(equalDescriptor, layerName.c_str()); armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0); inputLayer1->GetOutputSlot(0).Connect(equalLayer->GetInputSlot(0)); @@ -1111,10 +1110,7 @@ TEST_CASE("SerializeGather") } -// NOTE: Until the deprecated AddGreaterLayer disappears this test checks that calling -// AddGreaterLayer places a ComparisonLayer into the serialized format and that -// when this deserialises we have a ComparisonLayer -TEST_CASE("SerializeGreaterDeprecated") +TEST_CASE("SerializeComparisonGreater") { const std::string layerName("greater"); @@ -1126,9 +1122,8 @@ TEST_CASE("SerializeGreaterDeprecated") armnn::INetworkPtr network = armnn::INetwork::Create(); armnn::IConnectableLayer* const inputLayer0 = network->AddInputLayer(0); armnn::IConnectableLayer* const inputLayer1 = network->AddInputLayer(1); - ARMNN_NO_DEPRECATE_WARN_BEGIN - armnn::IConnectableLayer* const equalLayer = network->AddGreaterLayer(layerName.c_str()); - ARMNN_NO_DEPRECATE_WARN_END + armnn::ComparisonDescriptor greaterDescriptor(armnn::ComparisonOperation::Greater); + armnn::IConnectableLayer* const equalLayer = network->AddComparisonLayer(greaterDescriptor, layerName.c_str()); armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0); inputLayer0->GetOutputSlot(0).Connect(equalLayer->GetInputSlot(0)); @@ -1444,44 +1439,6 @@ public: } }; -// NOTE: Until the deprecated AddMergerLayer disappears this test checks that calling -// AddMergerLayer places a ConcatLayer into the serialized format and that -// when this deserialises we have a ConcatLayer -TEST_CASE("SerializeMerger") -{ - const std::string layerName("merger"); - const armnn::TensorInfo inputInfo = armnn::TensorInfo({2, 3, 2, 2}, armnn::DataType::Float32); - const armnn::TensorInfo outputInfo = armnn::TensorInfo({4, 3, 2, 2}, armnn::DataType::Float32); - - const std::vector<armnn::TensorShape> shapes({inputInfo.GetShape(), inputInfo.GetShape()}); - - armnn::OriginsDescriptor descriptor = - armnn::CreateDescriptorForConcatenation(shapes.begin(), shapes.end(), 0); - - armnn::INetworkPtr network = armnn::INetwork::Create(); - armnn::IConnectableLayer* const inputLayerOne = network->AddInputLayer(0); - armnn::IConnectableLayer* const inputLayerTwo = network->AddInputLayer(1); - ARMNN_NO_DEPRECATE_WARN_BEGIN - armnn::IConnectableLayer* const mergerLayer = network->AddMergerLayer(descriptor, layerName.c_str()); - ARMNN_NO_DEPRECATE_WARN_END - armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0); - - inputLayerOne->GetOutputSlot(0).Connect(mergerLayer->GetInputSlot(0)); - inputLayerTwo->GetOutputSlot(0).Connect(mergerLayer->GetInputSlot(1)); - mergerLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); - - inputLayerOne->GetOutputSlot(0).SetTensorInfo(inputInfo); - inputLayerTwo->GetOutputSlot(0).SetTensorInfo(inputInfo); - mergerLayer->GetOutputSlot(0).SetTensorInfo(outputInfo); - - std::string mergerLayerNetwork = SerializeNetwork(*network); - armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(mergerLayerNetwork); - CHECK(deserializedNetwork); - - MergerLayerVerifier verifier(layerName, {inputInfo, inputInfo}, {outputInfo}, descriptor); - deserializedNetwork->ExecuteStrategy(verifier); -} - TEST_CASE("EnsureMergerLayerBackwardCompatibility") { // The hex data below is a flat buffer containing a simple network with two inputs @@ -1979,14 +1936,14 @@ TEST_CASE("SerializeResize") deserializedNetwork->ExecuteStrategy(verifier); } -class ResizeBilinearLayerVerifier : public LayerVerifierBaseWithDescriptor<armnn::ResizeBilinearDescriptor> +class ResizeBilinearLayerVerifier : public LayerVerifierBaseWithDescriptor<armnn::ResizeDescriptor> { public: ResizeBilinearLayerVerifier(const std::string& layerName, const std::vector<armnn::TensorInfo>& inputInfos, const std::vector<armnn::TensorInfo>& outputInfos, - const armnn::ResizeBilinearDescriptor& descriptor) - : LayerVerifierBaseWithDescriptor<armnn::ResizeBilinearDescriptor>( + const armnn::ResizeDescriptor& descriptor) + : LayerVerifierBaseWithDescriptor<armnn::ResizeDescriptor>( layerName, inputInfos, outputInfos, descriptor) {} void ExecuteStrategy(const armnn::IConnectableLayer* layer, @@ -2022,16 +1979,14 @@ public: } }; -// NOTE: Until the deprecated AddResizeBilinearLayer disappears this test checks that -// calling AddResizeBilinearLayer places a ResizeLayer into the serialized format -// and that when this deserialises we have a ResizeLayer TEST_CASE("SerializeResizeBilinear") { const std::string layerName("resizeBilinear"); const armnn::TensorInfo inputInfo = armnn::TensorInfo({1, 3, 5, 5}, armnn::DataType::Float32); const armnn::TensorInfo outputInfo = armnn::TensorInfo({1, 3, 2, 4}, armnn::DataType::Float32); - armnn::ResizeBilinearDescriptor desc; + armnn::ResizeDescriptor desc; + desc.m_Method = armnn::ResizeMethod::Bilinear; desc.m_TargetWidth = 4u; desc.m_TargetHeight = 2u; desc.m_AlignCorners = true; @@ -2039,9 +1994,7 @@ TEST_CASE("SerializeResizeBilinear") armnn::INetworkPtr network = armnn::INetwork::Create(); armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(0); - ARMNN_NO_DEPRECATE_WARN_BEGIN - armnn::IConnectableLayer* const resizeLayer = network->AddResizeBilinearLayer(desc, layerName.c_str()); - ARMNN_NO_DEPRECATE_WARN_END + armnn::IConnectableLayer* const resizeLayer = network->AddResizeLayer(desc, layerName.c_str()); armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0); inputLayer->GetOutputSlot(0).Connect(resizeLayer->GetInputSlot(0)); @@ -2060,7 +2013,7 @@ TEST_CASE("SerializeResizeBilinear") TEST_CASE("EnsureResizeBilinearBackwardCompatibility") { // The hex data below is a flat buffer containing a simple network with an input, - // a ResizeBilinearLayer (now deprecated) and an output + // a ResizeBilinearLayer (now deprecated and removed) and an output // // This test verifies that we can still deserialize this old-style model by replacing // the ResizeBilinearLayer with an equivalent ResizeLayer @@ -2105,7 +2058,7 @@ TEST_CASE("EnsureResizeBilinearBackwardCompatibility") const armnn::TensorInfo inputInfo = armnn::TensorInfo({1, 3, 5, 5}, armnn::DataType::Float32); const armnn::TensorInfo outputInfo = armnn::TensorInfo({1, 3, 2, 4}, armnn::DataType::Float32); - armnn::ResizeBilinearDescriptor descriptor; + armnn::ResizeDescriptor descriptor; descriptor.m_TargetWidth = 4u; descriptor.m_TargetHeight = 2u; |