diff --git a/pystencils/backends/cbackend.py b/pystencils/backends/cbackend.py index c15431d70ee25c1bff88aaa51fa96c746e236182..7665f9dfc3ad32ac8ea9ead994af46e48b6610fa 100644 --- a/pystencils/backends/cbackend.py +++ b/pystencils/backends/cbackend.py @@ -787,18 +787,14 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter): else: exp = expr.exp + # TODO the printer should not have any intelligence like this. + # TODO To remove all of these cases the vectoriser needs to be reworked. See loop cutting if exp.is_integer and exp.is_number and 0 < exp < 8: return self._print(sp.Mul(*[expr.base] * exp, evaluate=False)) - elif exp == -1: - return self.instruction_set['/'].format(one, self._print(expr.base), **self._kwargs) elif exp == 0.5: return root elif exp == -0.5: return self.instruction_set['/'].format(one, root, **self._kwargs) - elif exp.is_integer and exp.is_number and - 8 < exp < 0: - return self.instruction_set['/'].format(one, - self._print(sp.Mul(*[expr.base] * (-exp), evaluate=False)), - **self._kwargs) else: raise ValueError("Generic exponential not supported: " + str(expr)) diff --git a/pystencils_tests/test_conditional_vec.py b/pystencils_tests/test_conditional_vec.py index 644985b4871b1dccf50a6c50d783b771acf6864a..ebb25d50d58b2a1ba0c8a5b7a5e089f1e6a7ea5d 100644 --- a/pystencils_tests/test_conditional_vec.py +++ b/pystencils_tests/test_conditional_vec.py @@ -19,7 +19,7 @@ def test_vec_any(instruction_set, dtype): width = 4 # we don't know the actual value else: width = get_vector_instruction_set(dtype, instruction_set)['width'] - data_arr = np.zeros((4 * width, 4 * width), dtype=np.float64 if dtype == 'double' else np.float32) + data_arr = np.zeros((4 * width, 4 * width), dtype=dtype) data_arr[3:9, 1:3 * width - 1] = 1.0 data = ps.fields(f"data: {dtype}[2D]", data=data_arr) diff --git a/pystencils_tests/test_vectorization.py b/pystencils_tests/test_vectorization.py index fcb46952fbac918dd21b1601641851bec8a5d9aa..3718770b9384e0f01dd899c3afed298208fc95a9 100644 --- a/pystencils_tests/test_vectorization.py +++ b/pystencils_tests/test_vectorization.py @@ -261,7 +261,6 @@ def test_vectorised_pow(instruction_set=instruction_set): ast = ps.create_kernel(as1) vectorize(ast, instruction_set=instruction_set) - print(ast) ast.compile() ast = ps.create_kernel(as2) @@ -282,7 +281,6 @@ def test_vectorised_pow(instruction_set=instruction_set): ast = ps.create_kernel(as6) vectorize(ast, instruction_set=instruction_set) - ps.show_code(ast) ast.compile()