diff options
author | Samuel Yap <samuel.yap@arm.com> | 2022-08-19 11:14:38 +0100 |
---|---|---|
committer | Nikhil Raj <nikhil.raj@arm.com> | 2022-08-30 17:03:44 +0100 |
commit | a04f4a15575ddd778d3a330dbce629412e1ffc0c (patch) | |
tree | 5f9ec80ee2a2f941c475115a274a2ba18e3965ce /src/armnnDeserializer/Deserializer.cpp | |
parent | dc8ed9d75e54e914a970e137900930fa64a0782b (diff) | |
download | armnn-a04f4a15575ddd778d3a330dbce629412e1ffc0c.tar.gz |
IVGCVSW-7104: BatchMatMul Serializer/Deserializer Support
* Updated FlatBuffers schema for BatchMatMul layer type
* Added Serializer and Deserializer implementations for BatchMatMul
* Added unit tests for BatchMatMul serialization and deserialization
* Updated CMakeLists and docs
Signed-off-by: Samuel Yap <samuel.yap@arm.com>
Change-Id: Iad63afbd036a3eb648683eb7416a475561aa20cb
Diffstat (limited to 'src/armnnDeserializer/Deserializer.cpp')
-rw-r--r-- | src/armnnDeserializer/Deserializer.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp index a405cb92a5..702b060512 100644 --- a/src/armnnDeserializer/Deserializer.cpp +++ b/src/armnnDeserializer/Deserializer.cpp @@ -214,6 +214,7 @@ m_ParserFunctions(Layer_MAX+1, &IDeserializer::DeserializerImpl::ParseUnsupporte m_ParserFunctions[Layer_ActivationLayer] = &DeserializerImpl::ParseActivation; m_ParserFunctions[Layer_AdditionLayer] = &DeserializerImpl::ParseAdd; m_ParserFunctions[Layer_ArgMinMaxLayer] = &DeserializerImpl::ParseArgMinMax; + m_ParserFunctions[Layer_BatchMatMulLayer] = &DeserializerImpl::ParseBatchMatMul; m_ParserFunctions[Layer_BatchToSpaceNdLayer] = &DeserializerImpl::ParseBatchToSpaceNd; m_ParserFunctions[Layer_BatchNormalizationLayer] = &DeserializerImpl::ParseBatchNormalization; m_ParserFunctions[Layer_CastLayer] = &DeserializerImpl::ParseCast; @@ -292,6 +293,8 @@ LayerBaseRawPtr IDeserializer::DeserializerImpl::GetBaseLayer(const GraphPtr& gr return graphPtr->layers()->Get(layerIndex)->layer_as_AdditionLayer()->base(); case Layer::Layer_ArgMinMaxLayer: return graphPtr->layers()->Get(layerIndex)->layer_as_ArgMinMaxLayer()->base(); + case Layer::Layer_BatchMatMulLayer: + return graphPtr->layers()->Get(layerIndex)->layer_as_BatchMatMulLayer()->base(); case Layer::Layer_BatchToSpaceNdLayer: return graphPtr->layers()->Get(layerIndex)->layer_as_BatchToSpaceNdLayer()->base(); case Layer::Layer_BatchNormalizationLayer: @@ -1258,6 +1261,37 @@ void IDeserializer::DeserializerImpl::ParseArgMinMax(GraphPtr graph, unsigned in RegisterOutputSlots(graph, layerIndex, layer); } +void IDeserializer::DeserializerImpl::ParseBatchMatMul(GraphPtr graph, unsigned int layerIndex) +{ + CHECK_LAYERS(graph, 0, layerIndex); + + auto inputs = GetInputs(graph, layerIndex); + CHECK_LOCATION(); + CHECK_VALID_SIZE(inputs.size(), 2); + + auto outputs = GetOutputs(graph, layerIndex); + CHECK_VALID_SIZE(outputs.size(), 1); + + auto serializerLayer = graph->layers()->Get(layerIndex)->layer_as_BatchMatMulLayer(); + auto serializerDescriptor = serializerLayer->descriptor(); + + armnn::BatchMatMulDescriptor descriptor(serializerDescriptor->transposeX(), + serializerDescriptor->transposeY(), + serializerDescriptor->adjointX(), + serializerDescriptor->adjointY(), + ToDataLayout(serializerDescriptor->dataLayoutX()), + ToDataLayout(serializerDescriptor->dataLayoutY())); + + auto layerName = GetLayerName(graph, layerIndex); + IConnectableLayer* layer = m_Network->AddBatchMatMulLayer(descriptor, layerName.c_str()); + + armnn::TensorInfo outputTensorInfo = ToTensorInfo(outputs[0]); + layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo); + + RegisterInputSlots(graph, layerIndex, layer); + RegisterOutputSlots(graph, layerIndex, layer); +} + void IDeserializer::DeserializerImpl::ParseBatchToSpaceNd(GraphPtr graph, unsigned int layerIndex) { CHECK_LAYERS(graph, 0, layerIndex); |