From 67a9bf12ca0e0c91b25e26df4dcd8758e6bb0180 Mon Sep 17 00:00:00 2001 From: Benoit Chevallier-Mames Date: Tue, 12 Oct 2021 20:07:36 +0200 Subject: [PATCH] test: make that the tested function has integer inputs functions that we compile are supposed to have integer inputs and outputs --- .../common/optimization/test_float_fusing.py | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/common/optimization/test_float_fusing.py b/tests/common/optimization/test_float_fusing.py index 6118fc178..5192081e3 100644 --- a/tests/common/optimization/test_float_fusing.py +++ b/tests/common/optimization/test_float_fusing.py @@ -75,6 +75,23 @@ def mix_x_and_y_and_call_f(function, x, y): ) +def mix_x_and_y_into_range_0_to_1_and_call_f(function, x, y): + """Mix x and y and then call function, in such a way that the input to function is between + 0 and 1""" + x_p_1 = x + 0.1 + x_p_2 = x + 0.2 + x_p_4 = 1 - numpy.abs(numpy.sin(x_p_1 + x_p_2 + 0.3)) + x_p_3 = function(x_p_4) + return ( + x_p_3.astype(numpy.int32), + x_p_2.astype(numpy.int32), + (x_p_2 + 3).astype(numpy.int32), + x_p_3.astype(numpy.int32) + 67, + y, + (y + 4.7).astype(numpy.int32) + 3, + ) + + def mix_x_and_y_into_integer_and_call_f(function, x, y): """Mix x and y but keep the entry to function as an integer""" x_p_1 = x + 1 @@ -200,9 +217,9 @@ def subtest_fuse_float_unary_operations_correctness(fun, tensor_shape): input_list = [1, 2, 42, 44] super_fun_list = [mix_x_and_y_and_call_f] elif fun in [numpy.arctanh, numpy.arccos, numpy.arcsin, numpy.arctan]: - # Needs values between 0 and 1 - input_list = [0, 0.1, 0.2] - super_fun_list = [mix_x_and_y_and_call_f] + # Needs values between 0 and 1 in the call function + input_list = [0, 2, 42, 44] + super_fun_list = [mix_x_and_y_into_range_0_to_1_and_call_f] elif fun in [numpy.cosh, numpy.sinh, numpy.exp, numpy.exp2, numpy.expm1]: # Not too large values to avoid overflows input_list = [1, 2, 5, 11]