From 42c9bae449af7ee395fc0e52d4ca7cc9ad55edeb Mon Sep 17 00:00:00 2001 From: Jeremy Johnson Date: Tue, 1 Feb 2022 11:37:58 +0000 Subject: Update refmodel apply_scale_32: adjust range checking Fix up generated values for rescale tests Signed-off-by: Jeremy Johnson Change-Id: I28fc3b8f189d25a7ad8e5172d4d8a43b86820fcf --- reference_model/src/quant_util.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'reference_model/src') diff --git a/reference_model/src/quant_util.h b/reference_model/src/quant_util.h index 4f6a525..8c1b391 100644 --- a/reference_model/src/quant_util.h +++ b/reference_model/src/quant_util.h @@ -55,6 +55,16 @@ public: "apply_scale_32(): shift value should stay within [2, 62] but is " + std::to_string(shift); throw desc; } + int64_t low_val = -1L << (shift-2); + int64_t high_val = 1L << (shift-2); + if (value < low_val || value >= high_val) + { + std::string desc = + "apply_scale_32(): value should stay within [" + + std::to_string(low_val) + ", " + std::to_string(high_val-1) + + "] but is " + std::to_string(value) + " using shift of " + std::to_string(shift); + throw desc; + } int64_t round = 1L << (shift - 1); if (double_round) { -- cgit v1.2.1