diff options
author | Cathal Corbett <cathal.corbett@arm.com> | 2021-11-23 11:49:23 +0000 |
---|---|---|
committer | Cathal Corbett <cathal.corbett@arm.com> | 2021-11-23 16:52:46 +0000 |
commit | bddb2583f2fe3529787f55a4143b24db42951721 (patch) | |
tree | 37061e1bb32cc1d466cc04cdfbd85665c8542aa0 /src/armnn | |
parent | f7b5011298367c6d635b17ad029c627076072198 (diff) | |
download | armnn-bddb2583f2fe3529787f55a4143b24db42951721.tar.gz |
IVGCVSW-6610 No bounds checking performed when indexing PermutationVector elements.
* Added out of bounds index error checking to PermutationVector operator[] method
in Types.hpp.
* Added armnn unit tests to UnitsTests.cpp to check error when using
PermutationVector alone and with TransposeDescriptor and PermuteDescriptor.
* Added pyarmnn unit test to check error when using PermutationVector.
Signed-off-by: Cathal Corbett <cathal.corbett@arm.com>
Change-Id: Ie5a8090f07b571a6bdf79a8cad621c31cc1891b7
Diffstat (limited to 'src/armnn')
-rw-r--r-- | src/armnn/test/UtilsTests.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/armnn/test/UtilsTests.cpp b/src/armnn/test/UtilsTests.cpp index 1599d0cd35..63884374b3 100644 --- a/src/armnn/test/UtilsTests.cpp +++ b/src/armnn/test/UtilsTests.cpp @@ -269,6 +269,28 @@ TEST_CASE("PermuteQuantizationDim") CHECK(permuted.GetQuantizationDim().value() == 3U); } +TEST_CASE("EmptyPermuteVectorIndexOutOfBounds") +{ + armnn::PermutationVector pv = armnn::PermutationVector({}); + CHECK_THROWS_AS(pv[0], armnn::InvalidArgumentException); +} + +TEST_CASE("PermuteDescriptorIndexOutOfBounds") +{ + armnn::PermutationVector pv = armnn::PermutationVector({ 1u, 2u, 0u }); + armnn::PermuteDescriptor desc = armnn::PermuteDescriptor(pv); + CHECK_THROWS_AS(desc.m_DimMappings[3], armnn::InvalidArgumentException); + CHECK(desc.m_DimMappings[0] == 1u); +} + +TEST_CASE("TransposeDescriptorIndexOutOfBounds") +{ + armnn::PermutationVector pv = armnn::PermutationVector({ 2u, 1u, 0u }); + armnn::TransposeDescriptor desc = armnn::TransposeDescriptor(pv); + CHECK_THROWS_AS(desc.m_DimMappings[3], armnn::InvalidArgumentException); + CHECK(desc.m_DimMappings[2] == 0u); +} + TEST_CASE("PermuteVectorIterator") { // We're slightly breaking the spirit of std::array.end() because we're using it as a |