aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2020-05-14 11:51:33 +0100
committerSadik Armagan <sadik.armagan@arm.com>2020-05-14 11:51:33 +0100
commitbe6b3c292dee16d69ed1849f7cfb3febd4568ee3 (patch)
treea12b2d54cdae656a39a40e532faf85278c57e7e2
parent8a510e8e9ed22ec0bbd295b69a6700ad0ba7cfd8 (diff)
downloadandroid-nn-driver-be6b3c292dee16d69ed1849f7cfb3febd4568ee3.tar.gz
IVGCVSW-4531 StridedSlice Failures on HAL Drivers
* Check if the output is large enough to hold the slice in the driver Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: Iaef16167e891a41186de030324bb45b8bbca4d80
-rw-r--r--ConversionUtils.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp
index 1538133..8313d04 100644
--- a/ConversionUtils.hpp
+++ b/ConversionUtils.hpp
@@ -3599,6 +3599,26 @@ bool ConvertStridedSlice(const HalOperation& operation, const HalModel& model, C
return false;
}
+ // Check if slice can fit in a inferred output
+ armnn::TensorShape inputShape = inputInfo.GetShape();
+ for (unsigned int i = 0; i < inputShape.GetNumDimensions(); i++)
+ {
+ int stride = descriptor.m_Stride[i];
+ int start = descriptor.GetStartForAxis(inputShape, i);
+ int stop = descriptor.GetStopForAxis(inputShape, i, start);
+
+ if (descriptor.m_ShrinkAxisMask & (1 << i))
+ {
+ // If the difference between the start point and the end point of the slice on an axis being shrunk
+ // is greater than 1 then throw an error as the output will not be large enough to hold the slice
+ if (((descriptor.m_Begin[i] - descriptor.m_End[i]) > 1)
+ || ((descriptor.m_Begin[i] - descriptor.m_End[i]) < -1))
+ {
+ return Fail("%s: StridedSlice: Output will not be large enough to hold the slice", __func__);
+ }
+ }
+ }
+
armnn::IConnectableLayer* const layer = data.m_Network->AddStridedSliceLayer(descriptor);
assert(layer != nullptr);
input.Connect(layer->GetInputSlot(0));