diff options
author | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-07-13 19:46:11 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-08-06 09:25:26 +0000 |
commit | 81beae3a870004795275e9266bc43d845b9f78db (patch) | |
tree | 70af86f3c36c8e330c72770e6f1419ca7b2a4bb8 /src/armnnSerializer/Serializer.cpp | |
parent | 95e9efc28ce70a8cda93e722f5ce90ebc96bdd95 (diff) | |
download | armnn-81beae3a870004795275e9266bc43d845b9f78db.tar.gz |
IVGCVSW-6119 ConstTensorsAsInput: FullyConnected
* Constant weights and biases are now stored as Constant layers.
* Updated Serializer, Deserializer and unit tests to reflect this.
* Updated TfLiteDelegate, TfLiteParser and OnnxParser.
* Updated Schema with IsConstant and ConstantTensorsAsInputs.
* Updated Ref backend to handle constant weights and
bias as inputs rather than reading from member variables.
* Added dynamic or constant input EndToEnd tests.
!android-nn-driver:5959
Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com>
Change-Id: Ibf3cf437df1100e4b322b0d303c575c6339f9696
Diffstat (limited to 'src/armnnSerializer/Serializer.cpp')
-rw-r--r-- | src/armnnSerializer/Serializer.cpp | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/armnnSerializer/Serializer.cpp b/src/armnnSerializer/Serializer.cpp index 44cd1800c4..195b41657a 100644 --- a/src/armnnSerializer/Serializer.cpp +++ b/src/armnnSerializer/Serializer.cpp @@ -1126,7 +1126,6 @@ void SerializerStrategy::SerializeQuantizeLayer(const armnn::IConnectableLayer * // Build FlatBuffer for FullyConnected Layer void SerializerStrategy::SerializeFullyConnectedLayer(const armnn::IConnectableLayer* layer, const armnn::FullyConnectedDescriptor& fullyConnectedDescriptor, - const std::vector<armnn::ConstTensor>& constants, const char*) { // Create FlatBuffer BaseLayer @@ -1139,28 +1138,10 @@ void SerializerStrategy::SerializeFullyConnectedLayer(const armnn::IConnectableL fullyConnectedDescriptor.m_TransposeWeightMatrix, fullyConnectedDescriptor.m_ConstantWeights); - // Create FlatBuffer weights data - flatbuffers::Offset<serializer::ConstTensor> flatBufferWeights; - // Create FlatBuffer bias data - flatbuffers::Offset<serializer::ConstTensor> flatBufferBiases; - if (fullyConnectedDescriptor.m_ConstantWeights && !constants.empty()) - { - armnn::ConstTensor weights = constants.at(0); - flatBufferWeights = CreateConstTensorInfo(weights); - - if (fullyConnectedDescriptor.m_BiasEnabled) - { - armnn::ConstTensor biases = constants.at(1); - flatBufferBiases = CreateConstTensorInfo(biases); - } - } - // Create FlatBuffer FullyConnectedLayer auto flatBufferLayer = serializer::CreateFullyConnectedLayer(m_flatBufferBuilder, flatBufferBaseLayer, - flatBufferDescriptor, - flatBufferWeights, - flatBufferBiases); + flatBufferDescriptor); // Add created FullyConnectedLayer to the FlatBufferLayers CreateAnyLayer(flatBufferLayer.o, serializer::Layer::Layer_FullyConnectedLayer); @@ -1916,7 +1897,8 @@ flatbuffers::Offset<armnnSerializer::FeatureCompatibilityVersions> SerializerStr serializer::CreateFeatureCompatibilityVersions( m_flatBufferBuilder, 1, // Binding ids scheme version - 1 // Weights layout scheme version + 1, // Weights layout scheme version + 1 // Constant tensors as inputs version ); return versionsTable; } @@ -2110,7 +2092,7 @@ void SerializerStrategy::ExecuteStrategy(const armnn::IConnectableLayer* layer, { const armnn::FullyConnectedDescriptor& layerDescriptor = static_cast<const armnn::FullyConnectedDescriptor&>(descriptor); - SerializeFullyConnectedLayer(layer, layerDescriptor, constants, name); + SerializeFullyConnectedLayer(layer, layerDescriptor, name); break; } case armnn::LayerType::Gather : |