aboutsummaryrefslogtreecommitdiff
path: root/1.2
diff options
context:
space:
mode:
authorAron Virginas-Tar <Aron.Virginas-Tar@arm.com>2019-07-15 18:04:32 +0100
committerÁron Virginás-Tar <aron.virginas-tar@arm.com>2019-07-16 13:31:37 +0000
commit9fd373954d64fbae72d1726bbdfc57a18a3a2f6d (patch)
tree18aec5d50a59ff103bae3a2c1dd5b475ad7694e3 /1.2
parent2b173126319343e49d1f081cfb58eacd96afc715 (diff)
downloadandroid-nn-driver-9fd373954d64fbae72d1726bbdfc57a18a3a2f6d.tar.gz
IVGCVSW-3455 Support dynamic output shape in hal_1_2::HalPolicy::ConvertDepthwiseConv2d
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> Change-Id: Iba64a674d772a76ca071553cb423ed870fae9bfd
Diffstat (limited to '1.2')
-rw-r--r--1.2/HalPolicy.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/1.2/HalPolicy.cpp b/1.2/HalPolicy.cpp
index 69cc4713..0c57636c 100644
--- a/1.2/HalPolicy.cpp
+++ b/1.2/HalPolicy.cpp
@@ -340,7 +340,6 @@ bool HalPolicy::ConvertDepthwiseConv2d(const Operation& operation, const Model&
}
const armnn::TensorInfo& inputInfo = input.GetTensorInfo();
- const armnn::TensorInfo& outputInfo = GetTensorInfoForOperand(*output);
// ArmNN does not currently support non-fixed weights or bias
// Find the shape of the weights tensor. In AndroidNN this will be [ 1, H, W, I * M ]
@@ -447,6 +446,22 @@ bool HalPolicy::ConvertDepthwiseConv2d(const Operation& operation, const Model&
desc.m_BiasEnabled = true;
armnn::Optional<armnn::TensorInfo> biases(bias.GetInfo());
+ armnn::TensorInfo outputInfo = GetTensorInfoForOperand(*output);
+ if (IsDynamicOutput(outputInfo))
+ {
+ try
+ {
+ ALOGD("Output shape not set, will infer from inputs");
+ outputInfo.SetShape(InferDepthwiseConvolution2dOutputShape(inputInfo.GetShape(),
+ weights.GetInfo().GetShape(),
+ desc));
+ }
+ catch (armnn::Exception& e)
+ {
+ return Fail("%s: Could not infer dynamic output shape: %s", __func__, e.what());
+ }
+ }
+
bool isSupported = false;
FORWARD_LAYER_SUPPORT_FUNC(__func__,
IsDepthwiseConvolutionSupported,
@@ -457,6 +472,7 @@ bool HalPolicy::ConvertDepthwiseConv2d(const Operation& operation, const Model&
desc,
weights.GetInfo(),
biases);
+
if (!isSupported)
{
return false;
@@ -464,6 +480,7 @@ bool HalPolicy::ConvertDepthwiseConv2d(const Operation& operation, const Model&
armnn::IConnectableLayer* startLayer =
data.m_Network->AddDepthwiseConvolution2dLayer(desc, weights, armnn::Optional<armnn::ConstTensor>(bias));
+
if (!startLayer)
{
return Fail("%s: AddDepthwiseConvolution2dLayer failed", __func__);
@@ -477,7 +494,12 @@ bool HalPolicy::ConvertDepthwiseConv2d(const Operation& operation, const Model&
input.Connect(startLayer->GetInputSlot(0));
- return SetupAndTrackLayerOutputSlot<hal_1_2::HalPolicy>(operation, 0, *endLayer, model, data);
+ return SetupAndTrackLayerOutputSlot<hal_1_2::HalPolicy>(operation,
+ 0,
+ *endLayer,
+ model,
+ data,
+ armnn::Optional<armnn::TensorInfo>(outputInfo));
}
bool HalPolicy::ConvertMaximum(const Operation& operation, const Model& model, ConversionData& data)