Skip to content
Snippets Groups Projects
Commit 47600995 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Don't count (-1) * as a flop

parent f74a2af1
No related branches found
No related tags found
No related merge requests found
......@@ -126,7 +126,23 @@ class ExpressionOpCounter(CombineMapper):
else:
return ToCountMap()
map_product = map_sum
def map_product(self, expr):
from pymbolic.primitives import is_zero
if expr.children:
return ToCountMap(
{self.type_inf(expr): len(expr.children)-1}
) + sum(
self.rec(child)
for child in expr.children
# Do not count '(-1)* ' (as produced by
# subtraction in pymbolic): Assume this
# gets implemented as a sign flip or
# as subtraction. (Confirmed to be true on
# at least Nvidia 352.30.)
if not is_zero(child - 1))
else:
return ToCountMap()
def map_quotient(self, expr, *args):
return ToCountMap({self.type_inf(expr): 1}) \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment