diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-10-15 17:35:36 +0100 |
---|---|---|
committer | Áron Virginás-Tar <aron.virginas-tar@arm.com> | 2019-10-16 09:39:56 +0000 |
commit | 6fe5247f8997a04edfdd7c974c96a0a086ef3ab5 (patch) | |
tree | 52d6cc314797f7bf138a0b2d81491543e05b6900 /src/armnn/Descriptors.cpp | |
parent | 20bea0071d507772e303eb6f1c476bf1feac9be5 (diff) | |
download | armnn-6fe5247f8997a04edfdd7c974c96a0a086ef3ab5.tar.gz |
IVGCVSW-3991 Make Descriptor objects comparable and refactor LayerVisitor tests
* Implemented operator==() for Descriptor structs
* Refactored TestNameAndDescriptorLayerVisitor to eliminate code duplication
by using templates and taking advantage of the fact that descriptor objects
can now all be compared the same way using ==
* Cleaned up TestNameOnlylayerVisitor by moving all test cases for layers
that require a descriptor to TestNameAndDescriptorLayerVisitor
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: Iee38b04d68d34a5f4ec7e5790de39ecb7ab0fb80
Diffstat (limited to 'src/armnn/Descriptors.cpp')
-rw-r--r-- | src/armnn/Descriptors.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/armnn/Descriptors.cpp b/src/armnn/Descriptors.cpp index a6339cf08e..381d040683 100644 --- a/src/armnn/Descriptors.cpp +++ b/src/armnn/Descriptors.cpp @@ -124,6 +124,29 @@ OriginsDescriptor& OriginsDescriptor::operator=(OriginsDescriptor rhs) return *this; } +bool OriginsDescriptor::operator==(const OriginsDescriptor& rhs) const +{ + if (GetNumViews() != rhs.GetNumViews() || + GetNumDimensions() != rhs.GetNumDimensions() || + GetConcatAxis() != rhs.GetConcatAxis()) + { + return false; + } + + for (unsigned int i = 0u; i < GetNumViews(); ++i) + { + for (unsigned int j = 0u; j < GetNumDimensions(); ++j) + { + if (GetViewOrigin(i)[j] != rhs.GetViewOrigin(i)[j]) + { + return false; + } + } + } + + return true; +} + void OriginsDescriptor::SetConcatAxis(unsigned int concatAxis) { m_ConcatAxis = concatAxis; @@ -240,6 +263,27 @@ ViewsDescriptor& ViewsDescriptor::operator=(ViewsDescriptor rhs) return *this; } +bool ViewsDescriptor::operator==(const ViewsDescriptor& rhs) const +{ + if (GetNumViews() != rhs.GetNumViews() || GetNumDimensions() != rhs.GetNumDimensions()) + { + return false; + } + + for (unsigned int i = 0u; i < GetNumViews(); ++i) + { + for (unsigned int j = 0u; j < GetNumDimensions(); ++j) + { + if (GetViewOrigin(i)[j] != rhs.GetViewOrigin(i)[j] || GetViewSizes(i)[j] != rhs.GetViewSizes(i)[j]) + { + return false; + } + } + } + + return true; +} + uint32_t ViewsDescriptor::GetNumViews() const { return m_Origins.GetNumViews(); |