From e9b5aaa0e4ea533e053d2cec98e71435f0a2d407 Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Sun, 18 Aug 2019 11:44:53 +0200 Subject: [PATCH] Add expm1 test --- pystencils_tests/test_sympy_optimizations.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pystencils_tests/test_sympy_optimizations.py diff --git a/pystencils_tests/test_sympy_optimizations.py b/pystencils_tests/test_sympy_optimizations.py new file mode 100644 index 00000000..5882ae31 --- /dev/null +++ b/pystencils_tests/test_sympy_optimizations.py @@ -0,0 +1,17 @@ +import sympy as sp + +import pystencils + + +def test_sympy_optimizations(): + for target in ('cpu', 'gpu'): + x, y, z = pystencils.fields('x, y, z: float32[2d]') + + # Triggers Sympy's expm1 optimization + assignments = pystencils.AssignmentCollection({ + x[0, 0]: sp.exp(y[0, 0]) - 1 + }) + + ast = pystencils.create_kernel(assignments, target=target) + code = str(pystencils.show_code(ast)) + assert 'expm1(' in code -- GitLab