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

Make VectorArg, ScalarArg comparable and add persistent-dict key generation for them

parent 3070eb99
No related branches found
No related tags found
1 merge request!134Speed up enqueue
......@@ -334,10 +334,15 @@ class DtypedArgument(Argument):
self.name,
self.dtype)
def __eq__(self, other):
return (type(self) == type(other)
and self.dtype == other.dtype
and self.name == other.name)
class VectorArg(DtypedArgument):
def __init__(self, dtype, name, with_offset=False):
DtypedArgument.__init__(self, dtype, name)
super().__init__(dtype, name)
self.with_offset = with_offset
def declarator(self):
......@@ -350,6 +355,10 @@ class VectorArg(DtypedArgument):
return result
def __eq__(self, other):
return (super().__eq__(other)
and self.with_offset == other.with_offset)
class ScalarArg(DtypedArgument):
def declarator(self):
......@@ -1025,6 +1034,11 @@ def is_spirv(s):
# {{{ numpy key types builder
class _NumpyTypesKeyBuilder(KeyBuilderBase):
def update_for_VectorArg(self, key_hash, key): # noqa: N802
self.rec(key_hash, key.dtype)
self.update_for_str(key_hash, key.name)
self.rec(key_hash, key.with_offset)
def update_for_type(self, key_hash, key):
if issubclass(key, np.generic):
self.update_for_str(key_hash, key.__name__)
......
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