diff --git a/pystencils_tests/test_sympy_optimizations.py b/pystencils_tests/test_sympy_optimizations.py new file mode 100644 index 0000000000000000000000000000000000000000..5882ae3124dd3ae04b9fecf852491178e4b496ec --- /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