for (unsigned int i = 0; i < inputShape.GetNumDimensions(); i++)
{
+ int stride = m_Param.m_Stride[i];
+ int start = m_Param.GetStartForAxis(inputShape, i);
+ int stop = m_Param.GetStopForAxis(inputShape, i, start);
+
if (m_Param.m_ShrinkAxisMask & (1 << i))
{
+ // Don't take a slice from an axis being shrunk
+ if (m_Param.m_End[i] >= 2)
+ {
+ throw LayerValidationException(
+ "StridedSlice: Attempting to take slice from an axis being shrunk");
+ }
continue;
}
- int stride = m_Param.m_Stride[i];
- int start = m_Param.GetStartForAxis(inputShape, i);
- int stop = m_Param.GetStopForAxis(inputShape, i, start);
-
int newSize = stride > 0 ? ((stop - start) + stride - 1) / stride :
((start - stop) - stride - 1) / -stride;
BOOST_TEST(found != std::string::npos);
}
+inline void StridedSliceInvalidSliceEndToEndTest(std::vector<BackendId> backends)
+{
+ using namespace armnn;
+
+ // Create runtime in which test will run
+ IRuntime::CreationOptions options;
+ IRuntimePtr runtime(armnn::IRuntime::Create(options));
+
+ // build up the structure of the network
+ INetworkPtr net(INetwork::Create());
+
+ IConnectableLayer* input = net->AddInputLayer(0);
+
+ // Configure a strided slice with a stride the same size as the input but with a ShrinkAxisMask on the first
+ // dim of the output to make it too small to hold the specified slice.
+ StridedSliceDescriptor descriptor;
+ descriptor.m_Begin = {0, 0};
+ descriptor.m_End = {2, 3};
+ descriptor.m_Stride = {1, 1};
+ descriptor.m_BeginMask = 0;
+ descriptor.m_EndMask = 0;
+ descriptor.m_ShrinkAxisMask = 1;
+ IConnectableLayer* stridedSlice = net->AddStridedSliceLayer(descriptor);
+
+ IConnectableLayer* output0 = net->AddOutputLayer(0);
+
+ input->GetOutputSlot(0).Connect(stridedSlice->GetInputSlot(0));
+ stridedSlice->GetOutputSlot(0).Connect(output0->GetInputSlot(0));
+
+ input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 2, 3 }, DataType::Float32));
+ stridedSlice->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 3 }, DataType::Float32));
+
+ // Attempt to optimize the network and check that the correct exception is thrown
+ BOOST_CHECK_THROW(Optimize(*net, backends, runtime->GetDeviceSpec()), armnn::LayerValidationException);
+}
+
} // anonymous namespace
DequantizeEndToEndOffset<armnn::DataType::QAsymmU8>(defaultBackends);
}
+BOOST_AUTO_TEST_CASE(ClStridedSliceInvalidSliceEndToEndTest)
+{
+ StridedSliceInvalidSliceEndToEndTest(defaultBackends);
+}
+
BOOST_AUTO_TEST_CASE(ClGreaterSimpleEndToEndTest)
{
const std::vector<uint8_t> expectedOutput({ 0, 0, 0, 0, 1, 1, 1, 1,
ArgMinAxis3EndToEnd<armnn::DataType::QAsymmU8>(defaultBackends);
}
+BOOST_AUTO_TEST_CASE(NeonStridedSliceInvalidSliceEndToEndTest)
+{
+ StridedSliceInvalidSliceEndToEndTest(defaultBackends);
+}
+
BOOST_AUTO_TEST_CASE(NeonDetectionPostProcessRegularNmsTest, * boost::unit_test::disabled())
{
std::vector<float> boxEncodings({
ExportOutputWithSeveralOutputSlotConnectionsTest(defaultBackends);
}
+BOOST_AUTO_TEST_CASE(RefStridedSliceInvalidSliceEndToEndTest)
+{
+ StridedSliceInvalidSliceEndToEndTest(defaultBackends);
+}
+
#endif
BOOST_AUTO_TEST_SUITE_END()