src/armnnDeserializer/test/DeserializeConvolution2d.cpp
src/armnnDeserializer/test/DeserializeDivision.cpp
src/armnnDeserializer/test/DeserializeEqual.cpp
+ src/armnnDeserializer/test/DeserializeFloor.cpp
src/armnnDeserializer/test/DeserializeFullyConnected.cpp
src/armnnDeserializer/test/DeserializeMultiplication.cpp
src/armnnDeserializer/test/DeserializeNormalization.cpp
m_ParserFunctions[Layer_DivisionLayer] = &Deserializer::ParseDivision;
m_ParserFunctions[Layer_EqualLayer] = &Deserializer::ParseEqual;
m_ParserFunctions[Layer_FullyConnectedLayer] = &Deserializer::ParseFullyConnected;
+ m_ParserFunctions[Layer_FloorLayer] = &Deserializer::ParseFloor;
m_ParserFunctions[Layer_MinimumLayer] = &Deserializer::ParseMinimum;
m_ParserFunctions[Layer_MaximumLayer] = &Deserializer::ParseMaximum;
m_ParserFunctions[Layer_MultiplicationLayer] = &Deserializer::ParseMultiplication;
return graphPtr->layers()->Get(layerIndex)->layer_as_EqualLayer()->base();
case Layer::Layer_FullyConnectedLayer:
return graphPtr->layers()->Get(layerIndex)->layer_as_FullyConnectedLayer()->base();
+ case Layer::Layer_FloorLayer:
+ return graphPtr->layers()->Get(layerIndex)->layer_as_FloorLayer()->base();
case Layer::Layer_InputLayer:
return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->base();
case Layer::Layer_MinimumLayer:
RegisterOutputSlots(graph, layerIndex, layer);
}
+void Deserializer::ParseFloor(GraphPtr graph, unsigned int layerIndex)
+{
+ CHECK_LAYERS(graph, 0, layerIndex);
+ CHECK_LOCATION();
+
+ auto inputs = GetInputs(graph, layerIndex);
+ CHECK_VALID_SIZE(inputs.size(), 1);
+
+ auto outputs = GetOutputs(graph, layerIndex);
+ CHECK_VALID_SIZE(outputs.size(), 1);
+
+ auto layerName = GetLayerName(graph, layerIndex);
+
+ armnn::IConnectableLayer* layer;
+
+ layer = m_Network->AddFloorLayer();
+
+ armnn::TensorInfo outputTensorInfo = ToTensorInfo(outputs[0]);
+ layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+
+ RegisterInputSlots(graph, layerIndex, layer);
+ RegisterOutputSlots(graph, layerIndex, layer);
+}
+
void Deserializer::ParseFullyConnected(GraphPtr graph, unsigned int layerIndex)
{
CHECK_LAYERS(graph, 0, layerIndex);
void ParseDepthwiseConvolution2d(GraphPtr graph, unsigned int layerIndex);
void ParseDivision(GraphPtr graph, unsigned int layerIndex);
void ParseEqual(GraphPtr graph, unsigned int layerIndex);
+ void ParseFloor(GraphPtr graph, unsigned int layerIndex);
void ParseFullyConnected(GraphPtr graph, unsigned int layerIndex);
void ParseMinimum(GraphPtr graph, unsigned int layerIndex);
void ParseMaximum(GraphPtr graph, unsigned int layerIndex);
* DepthwiseConvolution2d
* Division
* Equal
+* Floor
* FullyConnected
* Maximum
* Minimum
--- /dev/null
+//
+// 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 FloorFixture : public ParserFlatbuffersSerializeFixture
+{
+ explicit FloorFixture(const std::string& shape,
+ 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: )" + shape + R"(,
+ dataType: )" + dataType + R"(
+ }}]
+ }
+ }}},
+ {
+ layer_type: "FloorLayer",
+ layer: {
+ base: {
+ index: 1,
+ layerName: "FloorLayer",
+ layerType: "Floor",
+ inputSlots: [{
+ index: 0,
+ connection: {sourceLayerIndex:0, outputSlotIndex:0 },
+ }],
+ outputSlots: [ {
+ index: 0,
+ tensorInfo: {
+ dimensions: )" + shape + 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: )" + shape + R"(,
+ dataType: )" + dataType + R"(
+ },
+ }],
+ }}},
+ }]
+ }
+ )";
+ Setup();
+ }
+};
+
+
+struct SimpleFloorFixture : FloorFixture
+{
+ SimpleFloorFixture() : FloorFixture("[ 1, 3, 3, 1 ]",
+ "Float32") {}
+};
+
+BOOST_FIXTURE_TEST_CASE(Floor, SimpleFloorFixture)
+{
+ RunTest<4, armnn::DataType::Float32>(
+ 4,
+ {{"InputLayer", { -37.5f, -15.2f, -8.76f, -2.0f, -1.5f, -1.3f, -0.5f, -0.4f, 0.0f}}},
+ {{"OutputLayer",{ -38.0f, -16.0f, -9.0f, -2.0f, -2.0f, -2.0f, -1.0f, -1.0f, 0.0f}}});
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()
Maximum = 18,
Normalization = 19,
Pad = 20,
- Rsqrt = 21
+ Rsqrt = 21,
+ Floor = 22
}
// Base layer table to be used as part of other layers
base:LayerBase;
}
+table FloorLayer{
+ base:LayerBase;
+}
+
table FullyConnectedLayer {
base:LayerBase;
descriptor:FullyConnectedDescriptor;
MaximumLayer,
NormalizationLayer,
PadLayer,
- RsqrtLayer
+ RsqrtLayer,
+ FloorLayer
}
table AnyLayer {
CreateAnyLayer(fbEqualLayer.o, serializer::Layer::Layer_EqualLayer);
}
+void SerializerVisitor::VisitFloorLayer(const armnn::IConnectableLayer *layer, const char *name)
+{
+ auto flatBufferFloorBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Floor);
+ auto flatBufferFloorLayer = serializer::CreateFloorLayer(m_flatBufferBuilder, flatBufferFloorBaseLayer);
+
+ CreateAnyLayer(flatBufferFloorLayer.o, serializer::Layer::Layer_FloorLayer);
+}
+
void SerializerVisitor::VisitMinimumLayer(const armnn::IConnectableLayer* layer, const char* name)
{
auto fbMinimumBaseLayer = CreateLayerBase(layer, serializer::LayerType::LayerType_Minimum);
void VisitEqualLayer(const armnn::IConnectableLayer* layer,
const char* name = nullptr) override;
+ void VisitFloorLayer(const armnn::IConnectableLayer *layer,
+ const char *name = nullptr) override;
+
void VisitFullyConnectedLayer(const armnn::IConnectableLayer* layer,
const armnn::FullyConnectedDescriptor& fullyConnectedDescriptor,
const armnn::ConstTensor& weights,
* DepthwiseConvolution2d
* Division
* Equal
+* Floor
* FullyConnected
* Maximum
* Minimum
{commonTensorInfo.GetShape()});
}
+BOOST_AUTO_TEST_CASE(SerializeFloor)
+{
+ class VerifyFloorName : public armnn::LayerVisitorBase<armnn::VisitorNoThrowPolicy>
+ {
+ public:
+ void VisitMultiplicationLayer(const armnn::IConnectableLayer*, const char* name) override
+ {
+ BOOST_TEST(name == "floor");
+ }
+ };
+
+ const armnn::TensorInfo info({4,4}, armnn::DataType::Float32);
+
+ armnn::INetworkPtr network = armnn::INetwork::Create();
+ armnn::IConnectableLayer* const inputLayer = network->AddInputLayer(1);
+
+ const char* floorLayerName = "floor";
+
+ armnn::IConnectableLayer* const floorLayer = network->AddFloorLayer(floorLayerName);
+ inputLayer->GetOutputSlot(0).Connect(floorLayer->GetInputSlot(0));
+
+ armnn::IConnectableLayer* const outputLayer = network->AddOutputLayer(0);
+ floorLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
+
+ inputLayer->GetOutputSlot(0).SetTensorInfo(info);
+ floorLayer->GetOutputSlot(0).SetTensorInfo(info);
+
+ armnnSerializer::Serializer serializer;
+ serializer.Serialize(*network);
+
+ std::stringstream stream;
+ serializer.SaveSerializedToStream(stream);
+ BOOST_TEST(stream.str().length() > 0);
+ BOOST_TEST(stream.str().find(floorLayerName) != stream.str().npos);
+
+ armnn::INetworkPtr deserializedNetwork = DeserializeNetwork(stream.str());
+ BOOST_CHECK(deserializedNetwork);
+
+ VerifyFloorName nameChecker;
+ deserializedNetwork->Accept(nameChecker);
+}
+
BOOST_AUTO_TEST_CASE(SerializeMinimum)
{
class VerifyMinimumName : public armnn::LayerVisitorBase<armnn::VisitorNoThrowPolicy>