Skip to content
Snippets Groups Projects
Commit 705bf512 authored by James Stevens's avatar James Stevens
Browse files

added getitem, setitem to TypeToOpCountMap

parent dc953acd
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,15 @@ class TypeToOpCountMap:
__rmul__ = __mul__
def __getitem__(self, index):
try:
return self.dict[index]
except KeyError:
return isl.PwQPolynomial('{ 0 }')
def __setitem__(self, index, value):
self.dict[index] = value
def __str__(self):
return str(self.dict)
......
......@@ -143,7 +143,9 @@ def test_op_counter_bitwise(ctx_factory):
m = 256
l = 128
i32 = poly.dict[np.dtype(np.int32)].eval_with_dict({'n': n, 'm': m, 'l': l})
not_there = poly[np.dtype(np.float64)].eval_with_dict({'n': n, 'm': m, 'l': l})
assert i32 == 3*n*m+n*m*l
assert not_there == 0
if __name__ == "__main__":
if len(sys.argv) > 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