From fab64f09f49280ce7e57837c8bc99de31089512c Mon Sep 17 00:00:00 2001 From: Nattapat Chaimanowong Date: Fri, 15 Feb 2019 16:46:24 +0000 Subject: IVGCVSW-2730 Fix bug in TfParser setting incorrect output shape for Addition Layer *Output shape was incorrectly set for case when the 2 inputs have same number of dimensions and each dimension has different (but broadcast compatible) size Change-Id: Ia617442b2b7f962c33792b94035236d26de70558 Signed-off-by: Nattapat Chaimanowong --- src/armnnTfParser/TfParser.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/armnnTfParser/TfParser.cpp b/src/armnnTfParser/TfParser.cpp index b5fe6be075..0410460059 100755 --- a/src/armnnTfParser/TfParser.cpp +++ b/src/armnnTfParser/TfParser.cpp @@ -2910,7 +2910,25 @@ ParsedTfOperationPtr TfParser::AddAdditionLayer(const tensorflow::NodeDef& nodeD input0Slot->Connect(layer->GetInputSlot(0)); input1Slot->Connect(layer->GetInputSlot(1)); - if (input0Info.GetNumDimensions() == 1 && isBiasAdd == false) + if (input0Info.GetNumDimensions() == input1Info.GetNumDimensions()) + { + const TensorShape& input0Shape = input0Info.GetShape(); + const TensorShape& input1Shape = input1Info.GetShape(); + + std::vector outputShape; + outputShape.reserve(input0Shape.GetNumDimensions()); + TensorInfo outputInfo(input0Info); + + for (unsigned int i = 0; i < input0Shape.GetNumDimensions(); i++) + { + outputShape.push_back(std::max(input0Shape[i], input1Shape[i])); + } + + outputInfo.SetShape(TensorShape(input0Shape.GetNumDimensions(), outputShape.data())); + + layer->GetOutputSlot(0).SetTensorInfo(outputInfo); + } + else if (input0Info.GetNumDimensions() == 1 && isBiasAdd == false) { layer->GetOutputSlot(0).SetTensorInfo(input1Slot->GetTensorInfo()); } -- cgit v1.2.1