Skip to content

Commit

Permalink
Merge pull request #2518 from devitocodes/tweak-pow-to-mul
Browse files Browse the repository at this point in the history
compiler: Fixup pow_to_mul
  • Loading branch information
mloubout authored Jan 16, 2025
2 parents 603f6a7 + 93caaaa commit da2c9a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion devito/symbolics/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def pow_to_mul(expr):
# but at least we traverse the base looking for other Pows
return expr.func(pow_to_mul(base), exp, evaluate=False)
elif exp > 0:
return Mul(*[base]*int(exp), evaluate=False)
return Mul(*[pow_to_mul(base)]*int(exp), evaluate=False)
else:
# SymPy represents 1/x as Pow(x,-1). Also, it represents
# 2/x as Mul(2, Pow(x, -1)). So we shouldn't end up here,
Expand Down
1 change: 1 addition & 0 deletions tests/test_dse.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def test_scheduling_after_rewrite():
('sqrt(fa[x]**4)', 'sqrt(fa[x]*fa[x]*fa[x]*fa[x])'),
('sqrt(fa[x])**2', 'fa[x]'),
('fa[x]**-2', '1/(fa[x]*fa[x])'),
('cos(fa[x]*fa[x])*cos(fa[x]*fa[x])', 'cos(fa[x]*fa[x])*cos(fa[x]*fa[x])'),
])
def test_pow_to_mul(expr, expected):
grid = Grid((4, 5))
Expand Down

0 comments on commit da2c9a4

Please sign in to comment.