Skip to content

Commit

Permalink
Count flops in array initialisations
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- committed Jul 6, 2018
1 parent 5bb1b30 commit 8563a56
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions coffee/visitors/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ def visit_object(self, o, *args, **kwargs):
def visit_list(self, o, *args, **kwargs):
return sum(self.visit(e) for e in o)

def visit_ArrayInit(self, o, *args, **kwargs):
vals = o.values
if isinstance(vals, np.ndarray):
return sum(self.visit(vals[i]) for i in np.ndindex(vals.shape))
else:
return self.visit(vals)

def visit_Node(self, o, *args, **kwargs):
ops, _ = o.operands()
return sum(self.visit(op) for op in ops)
Expand Down

0 comments on commit 8563a56

Please sign in to comment.