Fix memory "near" tests for thresholds.
The current usage of TF_LITE_MICRO_EXPECT_NEAR() does not work as intended. The output of this function is:
if (actual > expected) {
delta = actual - expected
}
Given this logic, a "delta" of 0.03 will never work since the diff will always be a full integer. Fix this logic by multiplying the expected by the delta value.
PiperOrigin-RevId: 320113702
Change-Id: I81d510740a5a23ac6418faabbee74f39434e6336
diff --git a/tensorflow/lite/micro/memory_arena_threshold_test.cc b/tensorflow/lite/micro/memory_arena_threshold_test.cc
index f21c917..7a1f63b 100644
--- a/tensorflow/lite/micro/memory_arena_threshold_test.cc
+++ b/tensorflow/lite/micro/memory_arena_threshold_test.cc
@@ -95,7 +95,8 @@
// TODO(b/158651472): Better auditing of non-64 bit systems:
if (kIs64BitSystem) {
// 64-bit systems should check floor and ceiling to catch memory savings:
- TF_LITE_MICRO_EXPECT_NEAR(actual, expected, kAllocationThreshold);
+ TF_LITE_MICRO_EXPECT_NEAR(actual, expected,
+ expected * kAllocationThreshold);
if (actual != expected) {
TF_LITE_REPORT_ERROR(micro_test::reporter,
"%s threshold failed: %d != %d", allocation_type,