From 628526e79c769b8779df4a6af96360c33cde9d32 Mon Sep 17 00:00:00 2001 From: arghdos Date: Fri, 9 Dec 2016 13:07:35 -0500 Subject: [PATCH] add integer reduction tests --- test/test_loopy.py | 57 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/test/test_loopy.py b/test/test_loopy.py index 2438829f4..579215092 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -1935,34 +1935,35 @@ def test_unscheduled_insn_detection(): def test_integer_reduction(): n = 200 - var_int = np.random.randint(1000, size=n, dtype=np.int32) - var_lp = lp.TemporaryVariable('var', initializer=var_int, - scope=scopes.PRIVATE, - read_only=True, - dtype=np.int32, - shape=lp.auto) - - reductions = [('max', lambda x: x == np.max(var_int)), - ('min', lambda x: x == np.min(var_int)), - ('sum', lambda x: x == np.sum(var_int)), - ('product', lambda x: x == np.prod(var_int)), - ('argmax', lambda x: (x[0] == np.max(var_int) and - x[1] == np.argmax(var_int))), - ('argmin', lambda x: (x[0] == np.min(var_int) and - x[1] == np.argmin(var_int)))] - - for reduction, function in reductions: - kstr = (("out" if not 'arg' in reduction - else "out[0], out[1]") + ' = {}(k, var[k])'.format(reduction)) - knl = lp.make_kernel('{[k]: 0<=k 1: -- GitLab