From 23e00af42c1171286547e132ec3eaabb472fe9ea Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Wed, 13 May 2020 17:17:32 -0700 Subject: Fix incorrect (and inverted) comparison. This test was incorrectly passing this comparison before because the uninitialized value in `that.channelQuant->scales` was 0xaaaa... instead of not needing to be compared at all when `channelQuant` isn't set. Now we check whether to examine `scales` at all. Bug: http://b/156464649 Bug: http://b/156514991 Test: atest CtsNNAPITestCases:TensorRankConstraint Change-Id: I1f4db99bdd63e5dc1c95f574e6eca3adfffd138d (cherry picked from commit 63deac05d3a1d53430966a49c6979554f128383d) --- nn/runtime/test/TestValidateOperations.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'nn/runtime/test') diff --git a/nn/runtime/test/TestValidateOperations.cpp b/nn/runtime/test/TestValidateOperations.cpp index 4ac4f8d7d..01e4338d7 100644 --- a/nn/runtime/test/TestValidateOperations.cpp +++ b/nn/runtime/test/TestValidateOperations.cpp @@ -107,13 +107,17 @@ struct OperandTypeWithExtraParams { } } - if (channelQuant.has_value() && channelQuant->scales) { - return that.channelQuant->scales && - std::equal(channelQuant->scales, channelQuant->scales + channelQuant->scaleCount, - that.channelQuant->scales); - } else { - return that.channelQuant->scales != nullptr; + if (channelQuant.has_value()) { + if (channelQuant->scales) { + return that.channelQuant->scales && + std::equal(channelQuant->scales, + channelQuant->scales + channelQuant->scaleCount, + that.channelQuant->scales); + } else { + return that.channelQuant->scales == nullptr; + } } + return true; } bool operator!=(const OperandTypeWithExtraParams& that) const { return !(*this == that); } -- cgit v1.2.3