Skip to content
Snippets Groups Projects

Address #13: Use sympy.codegen.rewriting.optimize

Merged Stephan Seitz requested to merge seitz/pystencils:use_codegen.rewriting.optimize into master
Viewing commit 0c671ea0
Show latest version
1 file
+ 17
0
Preferences
Compare changes
+ 17
0
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